// File: /workspace/github_cpp_makefile_star2_O1/sharmaeklavya2[P]ddos-on-anycast/src/lib/network_grow.cpp
// Function: Network::vgrow(GrowParams const&, int)
void Network::vgrow(const GrowParams& grow_params, int seed) {

    int n_leaves_rough = depthwise.back().size();
    depthwise.emplace_back();
    int expected_children = grow_params.num_children * n_leaves_rough;
    depthwise.back().reserve(expected_children);
    reserve(size() + expected_children);
    rng_t rng1(seed);

    rng_t rng2(rng1());
    for(int u: depthwise[depthwise.size()-2]) {
        if(!is_virtual(u)) {
            rng_t rng3(rng2());
            int n = do_sigma_n(grow_params.num_children, grow_params.num_children_sigma, rng3);
            int vfirst = make_new_vertices(n, nid[u]);
            int vend = vfirst + n;
            for(int v=vfirst; v<vend; ++v) {
                depth[v] = depth[u]+1;
                depthwise.back().push_back(v);
                add_upward_edge(v, u);
                // optionally add extra upstreams
                rng_t rng4(rng3());
                while(runidist(0, 1, rng4) < grow_params.prob_multi_upstream) {
                    int u2;
                    if(in_nbrs[u].size() + side_nbrs[u].size() == 0 ||
                        runidist(0, 1, rng4) < grow_params.prob_self_multi_upstream) {
                        u2 = u;
                    }
                    else {
                        u2 = sample(in_nbrs[u], side_nbrs[u], rng4);
                    }
                    add_upward_edge(v, u2);
                }
            }
        }
    }

    // add side edges
    rng2.seed(rng1());
    for(int v: depthwise.back()) {
        rng_t rng3(rng2());
        while(runidist(0, 1, rng3) < grow_params.prob_side_peering) {
            ivec weights, items;
            items.reserve(up_nbrs[v].size());
            weights.reserve(up_nbrs[v].size());
            for(int u: up_nbrs[v]) {
                if(down_nbrs[u].size() > 1) {
                    items.push_back(u);
                    weights.push_back(down_nbrs[u].size()-1);
                }
            }
            int u;
            if(weights.empty()) {
                u = sample(up_nbrs[v], rng3);
            }
            else {
                u = weighed_sample(items, weights, rng3);
            }
            int u2 = u;
            if(in_nbrs[u].size() + side_nbrs[u].size() > 0 &&
                runidist(0, 1, rng3) > grow_params.prob_self_side_peering) {
                u2 = sample(in_nbrs[u], side_nbrs[u], rng3);
            }
            int v2 = sample_other(down_nbrs[u2], v, rng3);
            if(v2 != v) {
                add_side_edge(v, v2);
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %edx, %ebp
movq %rdi, %rbx
movq 0xb0(%rdi), %rax
movq -0x10(%rax), %r14
subq -0x18(%rax), %r14
movq %rsi, %r13
shrq $0x2, %r14
cmpq 0xb8(%rdi), %rax
je 0x4ff3
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq $0x0, 0x10(%rax)
addq $0x18, 0xb0(%rbx)
jmp 0x5002
leaq 0xa8(%rbx), %rdi
movq %rax, %rsi
callq 0x6086
movslq (%r13), %rax
movslq %r14d, %r15
imulq %rax, %r15
movq 0xb0(%rbx), %rdi
addq $-0x18, %rdi
movq %r15, %rsi
callq 0x58be
movq 0x20(%rbx), %rsi
subq 0x18(%rbx), %rsi
shrq $0x2, %rsi
addl %r15d, %esi
movq %rbx, %rdi
callq 0x594c
movslq %ebp, %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
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, 0x90(%rsp)
movq 0xb0(%rbx), %rax
movq -0x30(%rax), %rsi
movq -0x28(%rax), %rcx
cmpq %rcx, %rsi
movq %r13, 0x80(%rsp)
je 0x53dd
movq 0x90(%rsp), %rax
cmpq $0x1, %rax
movq %rax, %rdx
adcq $0x0, %rdx
leaq 0x10(%rsp), %r12
movq %rcx, 0x98(%rsp)
movl (%rsi), %r14d
movslq %r14d, %r15
movq 0x18(%rbx), %rax
cmpl $0x0, (%rax,%r15,4)
jg 0x53d0
imulq $0xbc8f, %rdx, %rcx     # imm = 0xBC8F
movq %rcx, %rax
movabsq $0x200000005, %rdx      # imm = 0x200000005
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
movq %rdx, 0xa0(%rsp)
cmpq $0x1, %rdx
adcq %rcx, %rax
movq %rax, 0x50(%rsp)
movl (%r13), %ebp
movsd 0x8(%r13), %xmm0
ucomisd 0x8372(%rip), %xmm0     # 0xd4c0
movq %rsi, 0x70(%rsp)
jne 0x5157
jnp 0x51ae
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movsd %xmm1, 0x18(%rsp)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x20(%rsp)
movsd %xmm0, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
movb $0x0, 0x38(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movq %rdi, %rdx
callq 0x5dba
mulsd 0x18(%rsp), %xmm0
cvttsd2si %xmm0, %ebp
cmpl $0x2, %ebp
movl $0x1, %eax
cmovll %eax, %ebp
movq (%rbx), %rax
movl (%rax,%r15,4), %edx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2938
movl %eax, 0x8(%rsp)
testl %ebp, %ebp
jle 0x53bb
addl %eax, %ebp
movl %ebp, 0x18(%rsp)
movl %r14d, 0x48(%rsp)
movq %r15, 0x78(%rsp)
movq 0x30(%rbx), %rcx
movl (%rcx,%r15,4), %edx
incl %edx
cltq
movl %edx, (%rcx,%rax,4)
movq 0xb0(%rbx), %rdi
movq -0x10(%rdi), %rsi
cmpq -0x8(%rdi), %rsi
je 0x520b
movl 0x8(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x10(%rdi)
jmp 0x5219
addq $-0x18, %rdi
leaq 0x8(%rsp), %rdx
callq 0x3e1c
movl 0x8(%rsp), %esi
movq %rbx, %rdi
movl %r14d, %edx
callq 0x2b0c
imulq $0xbc8f, 0x50(%rsp), %rcx # imm = 0xBC8F
movq %rcx, %rax
movabsq $0x200000005, %rdx      # imm = 0x200000005
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
movq %rdx, 0x50(%rsp)
cmpq $0x1, %rdx
adcq %rcx, %rax
movq %rax, 0x10(%rsp)
movq %r12, %rdi
callq 0x5eb2
movsd 0x10(%r13), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x53a7
leaq (,%r15,8), %rax
leaq (%rax,%rax,2), %rbp
movq 0x48(%rbx), %rax
movq 0x8(%rax,%rbp), %rcx
subq (%rax,%rbp), %rcx
movq 0x60(%rbx), %rax
movq 0x8(%rax,%rbp), %rsi
subq (%rax,%rbp), %rsi
sarq $0x2, %rcx
sarq $0x2, %rsi
movl %r14d, %edx
addq %rcx, %rsi
je 0x538f
movq %r12, %rdi
callq 0x5eb2
movsd 0x18(%r13), %xmm1
ucomisd %xmm0, %xmm1
movl %r14d, %edx
ja 0x538f
movq 0x48(%rbx), %r14
movq 0x60(%rbx), %r13
movq 0x8(%r14,%rbp), %rax
subq (%r14,%rbp), %rax
shrq $0x2, %rax
movq 0x8(%r13,%rbp), %rcx
subq (%r13,%rbp), %rcx
shrq $0x2, %rcx
addl %ecx, %eax
decl %eax
movl $0x0, 0x20(%rsp)
movl %eax, 0x24(%rsp)
leaq 0x20(%rsp), %rdi
movq %r12, %r15
movq %r12, %rsi
movq %rdi, %rdx
callq 0x5b5e
movl %eax, %r12d
movq 0x8(%r14,%rbp), %rax
subq (%r14,%rbp), %rax
sarq $0x2, %rax
movq 0x8(%r13,%rbp), %rcx
subq (%r13,%rbp), %rcx
sarq $0x2, %rcx
addq %rax, %rcx
je 0x53a0
addq %rbp, %r14
addq %rbp, %r13
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
movl %r12d, %edx
subl %ecx, %edx
movslq %edx, %rdx
shlq $0x2, %rdx
addq (%r13), %rdx
cmpl %ecx, %r12d
movslq %r12d, %rcx
leaq (%rax,%rcx,4), %rax
cmovgeq %rdx, %rax
movl (%rax), %edx
movq 0x80(%rsp), %r13
movq %r15, %r12
movl 0x48(%rsp), %r14d
movq 0x78(%rsp), %r15
movl 0x8(%rsp), %esi
movq %rbx, %rdi
callq 0x2b0c
jmp 0x5270
callq 0x2312
jmp 0x5346
movl 0x8(%rsp), %eax
incl %eax
movl %eax, 0x8(%rsp)
cmpl 0x18(%rsp), %eax
jl 0x51db
movq 0x70(%rsp), %rsi
movq 0x98(%rsp), %rcx
movq 0xa0(%rsp), %rdx
addq $0x4, %rsi
cmpq %rcx, %rsi
jne 0x50de
movq 0xb0(%rbx), %rax
movq -0x18(%rax), %rsi
movq -0x10(%rax), %rax
movq %rax, 0x70(%rsp)
cmpq %rax, %rsi
je 0x583d
imulq $0xbc8f, 0x90(%rsp), %rcx # imm = 0xBC8F
movq %rcx, %rax
movabsq $0x200000005, %rdx      # imm = 0x200000005
mulq %rdx
movq %rcx, %rdi
subq %rdx, %rdi
shrq %rdi
addq %rdx, %rdi
shrq $0x1e, %rdi
movq %rdi, %rax
shlq $0x1f, %rax
subq %rax, %rdi
leaq (%rcx,%rdi), %rax
cmpq $0x1, %rax
adcq %rcx, %rdi
leaq 0x8(%rsp), %r15
leaq 0x10(%rsp), %rbp
movq %rsi, 0x78(%rsp)
movl (%rsi), %r12d
imulq $0xbc8f, %rdi, %rcx     # imm = 0xBC8F
movq %rcx, %rax
movabsq $0x200000005, %rdx      # imm = 0x200000005
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
movq %rdx, 0x18(%rsp)
cmpq $0x1, %rdx
adcq %rcx, %rax
movq %rax, 0x8(%rsp)
movq %r15, %rdi
callq 0x5eb2
movsd 0x20(%r13), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x5824
movslq %r12d, %rax
leaq (%rax,%rax,2), %r14
movq %r14, 0x48(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
xorl %eax, %eax
movq %rax, 0x30(%rsp)
movq %rax, 0x60(%rsp)
movapd %xmm0, 0x50(%rsp)
movq 0x78(%rbx), %rax
movq 0x8(%rax,%r14,8), %rsi
subq (%rax,%r14,8), %rsi
sarq $0x2, %rsi
leaq 0x50(%rsp), %rdi
callq 0x58be
movq 0x78(%rbx), %rax
movq 0x8(%rax,%r14,8), %rsi
subq (%rax,%r14,8), %rsi
sarq $0x2, %rsi
leaq 0x20(%rsp), %rdi
callq 0x58be
movq 0x78(%rbx), %rax
movq (%rax,%r14,8), %r13
movq 0x8(%rax,%r14,8), %r14
cmpq %r14, %r13
je 0x55c1
movslq (%r13), %rax
movl %eax, 0x10(%rsp)
movq 0x90(%rbx), %rcx
leaq (%rax,%rax,2), %rdx
movq 0x8(%rcx,%rdx,8), %rsi
subq (%rcx,%rdx,8), %rsi
cmpq $0x5, %rsi
jb 0x55b8
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x555a
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x58(%rsp)
jmp 0x5567
leaq 0x50(%rsp), %rdi
movq %rbp, %rdx
callq 0x3e1c
movslq 0x10(%rsp), %rax
movq 0x90(%rbx), %rcx
leaq (%rax,%rax,2), %rdx
movq 0x8(%rcx,%rdx,8), %rax
subq (%rcx,%rdx,8), %rax
shrq $0x2, %rax
decl %eax
movl %eax, 0x8c(%rsp)
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x55a6
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x55b8
leaq 0x20(%rsp), %rdi
leaq 0x8c(%rsp), %rdx
callq 0x3f50
addq $0x4, %r13
jmp 0x5516
movq 0x20(%rsp), %rax
cmpq 0x28(%rsp), %rax
je 0x55e4
leaq 0x50(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %r15, %rdx
callq 0x59b3
movl %eax, %r13d
jmp 0x5630
movq 0x78(%rbx), %r14
movq 0x48(%rsp), %r13
movq (%r14,%r13,8), %rax
cmpq 0x8(%r14,%r13,8), %rax
je 0x580a
leaq (%r14,%r13,8), %r14
movq 0x8(%r14), %rax
subq (%r14), %rax
shrq $0x2, %rax
decl %eax
movl $0x0, 0x10(%rsp)
movl %eax, 0x14(%rsp)
movq %rbp, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x5b5e
cltq
movq (%r14), %rcx
movl (%rcx,%rax,4), %r13d
movslq %r13d, %rax
shlq $0x3, %rax
leaq (%rax,%rax,2), %r15
movq 0x48(%rbx), %rax
movq 0x60(%rbx), %rcx
movq 0x8(%rax,%r15), %rdx
subq (%rax,%r15), %rdx
sarq $0x2, %rdx
movq 0x8(%rcx,%r15), %rax
subq (%rcx,%r15), %rax
sarq $0x2, %rax
addq %rdx, %rax
je 0x5719
leaq 0x8(%rsp), %rdi
callq 0x5eb2
movq 0x80(%rsp), %rax
ucomisd 0x28(%rax), %xmm0
jbe 0x5719
movq 0x48(%rbx), %r13
movq 0x60(%rbx), %r14
movq 0x8(%r13,%r15), %rax
subq (%r13,%r15), %rax
shrq $0x2, %rax
movq 0x8(%r14,%r15), %rcx
subq (%r14,%r15), %rcx
shrq $0x2, %rcx
addl %ecx, %eax
decl %eax
movl $0x0, 0x10(%rsp)
movl %eax, 0x14(%rsp)
movq %rbp, %rdi
leaq 0x8(%rsp), %rsi
movq %rbp, %rdx
callq 0x5b5e
addq %r15, %r13
addq %r15, %r14
movq 0x8(%r13), %rdx
subq (%r13), %rdx
sarq $0x2, %rdx
movq 0x8(%r14), %rcx
subq (%r14), %rcx
sarq $0x2, %rcx
addq %rdx, %rcx
je 0x5814
movq (%r13), %rsi
movq 0x8(%r13), %rcx
subq %rsi, %rcx
shrq $0x2, %rcx
movl %eax, %edx
subl %ecx, %edx
movslq %edx, %rdx
shlq $0x2, %rdx
addq (%r14), %rdx
cmpl %ecx, %eax
movslq %eax, %rcx
leaq (%rsi,%rcx,4), %rax
cmovgeq %rdx, %rax
movl (%rax), %r13d
movslq %r13d, %rax
movq 0x90(%rbx), %rsi
leaq (%rax,%rax,2), %rdi
movq (%rsi,%rdi,8), %rcx
movq 0x8(%rsi,%rdi,8), %rax
movl %r12d, %edx
cmpq %rax, %rcx
movq 0x80(%rsp), %r13
leaq 0x8(%rsp), %r15
je 0x5774
leaq (%rsi,%rdi,8), %r14
addq $0x4, %rcx
movb $0x1, %sil
xorl %edi, %edi
movzbl %sil, %esi
cmpl %r12d, -0x4(%rcx)
cmovnel %edi, %esi
jne 0x576b
leaq 0x4(%rcx), %rdx
cmpq %rax, %rcx
movq %rdx, %rcx
jne 0x5752
movl %r12d, %edx
testb $0x1, %sil
je 0x57c1
cmpl %r12d, %edx
je 0x5784
movq %rbx, %rdi
movl %r12d, %esi
callq 0x2a10
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x5793
callq 0x2150
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
movq 0x48(%rsp), %r14
je 0x57a7
callq 0x2150
movq %r15, %rdi
callq 0x5eb2
movsd 0x20(%r13), %xmm1
ucomisd %xmm0, %xmm1
ja 0x54b7
jmp 0x5824
movq (%r14), %rax
cmpq 0x8(%r14), %rax
je 0x5803
movq 0x8(%r14), %rax
subq (%r14), %rax
shrq $0x2, %rax
decl %eax
movl $0x0, 0x10(%rsp)
movl %eax, 0x14(%rsp)
movq %rbp, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x5b5e
cltq
movq (%r14), %rcx
movl (%rcx,%rax,4), %edx
cmpl %r12d, %edx
je 0x57c1
jmp 0x5774
callq 0x2378
jmp 0x57ca
callq 0x2334
jmp 0x55fc
movl %eax, %r15d
callq 0x2356
movl %r15d, %eax
jmp 0x56ec
movq 0x78(%rsp), %rsi
addq $0x4, %rsi
cmpq 0x70(%rsp), %rsi
movq 0x18(%rsp), %rdi
jne 0x5445
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x585b
jmp 0x585b
jmp 0x585b
jmp 0x585b
jmp 0x585b
jmp 0x585b
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x586d
callq 0x2150
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x587c
callq 0x2150
movq %rbx, %rdi
callq 0x2220