// File: /workspace/github_cpp_makefile_star2_O3/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 $0x98, %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 0x4e91
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq 0xb0(%rbx), %rdi
addq $0x18, %rdi
movq %rdi, 0xb0(%rbx)
jmp 0x4ea7
leaq 0xa8(%rbx), %rdi
movq %rax, %rsi
callq 0x5f72
movq 0xb0(%rbx), %rdi
movslq (%r13), %rax
movslq %r14d, %r15
imulq %rax, %r15
addq $-0x18, %rdi
movq %r15, %rsi
callq 0x57a4
movq 0x20(%rbx), %rsi
subq 0x18(%rbx), %rsi
shrq $0x2, %rsi
addl %r15d, %esi
movq %rbx, %rdi
callq 0x5836
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 0xb0(%rbx), %rax
movq -0x30(%rax), %rcx
movq -0x28(%rax), %rsi
cmpq %rsi, %rcx
movq %r13, 0x48(%rsp)
je 0x529f
cmpq $0x1, %rdx
movq %rdx, 0x80(%rsp)
adcq $0x0, %rdx
leaq 0x10(%rsp), %r12
movq %rsi, 0x88(%rsp)
movl (%rcx), %ebp
movslq %ebp, %r15
movq 0x18(%rbx), %rax
cmpl $0x0, (%rax,%r15,4)
jg 0x5283
movq %rcx, 0x68(%rsp)
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, 0x90(%rsp)
cmpq $0x1, %rdx
adcq %rcx, %rax
movq %rax, 0x50(%rsp)
movl (%r13), %r14d
movsd 0x8(%r13), %xmm0
ucomisd 0x74de(%rip), %xmm0     # 0xc4c0
jne 0x4fe6
jnp 0x5041
xorps %xmm1, %xmm1
cvtsi2sd %r14d, %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 0x5cb2
mulsd 0x18(%rsp), %xmm0
cvttsd2si %xmm0, %r14d
cmpl $0x2, %r14d
movl $0x1, %eax
cmovll %eax, %r14d
movq (%rbx), %rax
movl (%rax,%r15,4), %edx
movq %rbx, %rdi
movl %r14d, %esi
callq 0x2858
movl %eax, 0x8(%rsp)
testl %r14d, %r14d
jle 0x526e
addl %eax, %r14d
movl %r14d, 0x18(%rsp)
movl %ebp, 0x40(%rsp)
movq %r15, 0x70(%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 0x50a1
movl 0x8(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x10(%rdi)
jmp 0x50b3
addq $-0x18, %rdi
leaq 0x8(%rsp), %rdx
callq 0x3d28
movl 0x8(%rsp), %eax
movq %rbx, %rdi
movl %eax, %esi
movl %ebp, %edx
callq 0x2a2c
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 0x5daa
movsd 0x10(%r13), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x525a
leaq (,%r15,8), %rax
leaq (%rax,%rax,2), %r14
movq 0x48(%rbx), %rax
movq 0x8(%rax,%r14), %rcx
subq (%rax,%r14), %rcx
movq 0x60(%rbx), %rax
movq 0x8(%rax,%r14), %rsi
subq (%rax,%r14), %rsi
sarq $0x2, %rcx
sarq $0x2, %rsi
movl %ebp, %edx
addq %rcx, %rsi
je 0x5212
movq %r12, %rdi
callq 0x5daa
movsd 0x18(%r13), %xmm1
ucomisd %xmm0, %xmm1
movl %ebp, %edx
ja 0x5212
movq 0x48(%rbx), %r13
movq 0x60(%rbx), %rbp
movq 0x8(%r13,%r14), %rax
subq (%r13,%r14), %rax
shrq $0x2, %rax
movq 0x8(%rbp,%r14), %rcx
subq (%rbp,%r14), %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 0x5a56
movl %eax, %r12d
movq (%r13,%r14), %rax
movq 0x8(%r13,%r14), %rcx
subq %rax, %rcx
movq %rcx, %rsi
sarq $0x2, %rsi
movq (%rbp,%r14), %rdx
movq 0x8(%rbp,%r14), %rdi
subq %rdx, %rdi
sarq $0x2, %rdi
addq %rsi, %rdi
je 0x5223
shrq $0x2, %rcx
movslq %r12d, %rsi
subl %ecx, %r12d
leaq (%rax,%rsi,4), %rax
movslq %r12d, %rcx
leaq (%rdx,%rcx,4), %rcx
cmovlq %rax, %rcx
movl (%rcx), %edx
movq 0x48(%rsp), %r13
movq %r15, %r12
movl 0x40(%rsp), %ebp
movq 0x70(%rsp), %r15
movl 0x8(%rsp), %esi
movq %rbx, %rdi
callq 0x2a2c
jmp 0x5107
addq %r14, %r13
addq %r14, %rbp
movq 0xbda0(%rip), %rax      # 0x10fd0
movq (%rax), %rcx
movl $0x22, %esi
movl $0x1, %edx
leaq 0x739c(%rip), %rdi      # 0xc5e0
callq 0x2240
movq (%r13), %rax
movq 0x8(%r13), %rcx
movq (%rbp), %rdx
subq %rax, %rcx
jmp 0x51e6
movl 0x8(%rsp), %eax
incl %eax
movl %eax, 0x8(%rsp)
cmpl 0x18(%rsp), %eax
jl 0x5071
movq 0x68(%rsp), %rcx
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdx
addq $0x4, %rcx
cmpq %rsi, %rcx
jne 0x4f6e
movq 0xb0(%rbx), %rax
movq 0x80(%rsp), %rdx
movq -0x18(%rax), %rsi
movq -0x10(%rax), %rax
movq %rax, 0x68(%rsp)
cmpq %rax, %rsi
je 0x5722
imulq $0xbc8f, %rdx, %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, 0x70(%rsp)
movslq (%rsi), %r12
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 0x5daa
movsd 0x20(%r13), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x5709
leaq (%r12,%r12,2), %r14
movq %r14, 0x40(%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 0x57a4
movq 0x78(%rbx), %rax
movq 0x8(%rax,%r14,8), %rsi
subq (%rax,%r14,8), %rsi
sarq $0x2, %rsi
leaq 0x20(%rsp), %rdi
callq 0x57a4
movq 0x78(%rbx), %rax
movq (%rax,%r14,8), %r13
movq 0x8(%rax,%r14,8), %r14
cmpq %r14, %r13
je 0x546e
movslq (%r13), %rcx
movl %ecx, 0x10(%rsp)
movq 0x90(%rbx), %rax
leaq (%rcx,%rcx,2), %rdx
movq 0x8(%rax,%rdx,8), %rsi
subq (%rax,%rdx,8), %rsi
cmpq $0x5, %rsi
jb 0x5465
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x540d
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x58(%rsp)
jmp 0x5421
leaq 0x50(%rsp), %rdi
movq %rbp, %rdx
callq 0x3d28
movq 0x90(%rbx), %rax
movslq 0x10(%rsp), %rcx
leaq (%rcx,%rcx,2), %rdx
movq 0x8(%rax,%rdx,8), %rcx
subq (%rax,%rdx,8), %rcx
shrq $0x2, %rcx
decl %ecx
movl %ecx, 0x7c(%rsp)
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x5456
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x5465
leaq 0x20(%rsp), %rdi
leaq 0x7c(%rsp), %rdx
callq 0x3e5c
addq $0x4, %r13
jmp 0x53c9
movq 0x20(%rsp), %rax
cmpq 0x28(%rsp), %rax
je 0x548e
leaq 0x50(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %r15, %rdx
callq 0x589d
jmp 0x54d6
movq 0x78(%rbx), %rax
movq 0x40(%rsp), %rcx
leaq (%rax,%rcx,8), %r14
movq (%r14), %rcx
movq 0x8(%r14), %rax
cmpq %rax, %rcx
je 0x56a4
subq %rcx, %rax
shrq $0x2, %rax
decl %eax
movl $0x0, 0x10(%rsp)
movl %eax, 0x14(%rsp)
movq %rbp, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x5a56
movq (%r14), %rcx
cltq
movl (%rcx,%rax,4), %eax
movslq %eax, %r15
leaq (,%r15,8), %rax
leaq (%rax,%rax,2), %r14
movq 0x48(%rbx), %rax
movq 0x60(%rbx), %rcx
movq 0x8(%rax,%r14), %rdx
subq (%rax,%r14), %rdx
sarq $0x2, %rdx
movq 0x8(%rcx,%r14), %rax
subq (%rcx,%r14), %rax
sarq $0x2, %rax
addq %rdx, %rax
je 0x55bc
leaq 0x8(%rsp), %rdi
callq 0x5daa
movq 0x48(%rsp), %r13
ucomisd 0x28(%r13), %xmm0
jbe 0x55c1
movq 0x48(%rbx), %r15
movq 0x60(%rbx), %r13
movq 0x8(%r15,%r14), %rax
subq (%r15,%r14), %rax
shrq $0x2, %rax
movq 0x8(%r13,%r14), %rcx
subq (%r13,%r14), %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 0x5a56
movl %eax, %r8d
addq %r14, %r15
addq %r14, %r13
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
movq %rcx, %rsi
sarq $0x2, %rsi
movq (%r13), %rdx
movq 0x8(%r13), %rdi
subq %rdx, %rdi
sarq $0x2, %rdi
addq %rsi, %rdi
je 0x56d0
shrq $0x2, %rcx
movslq %r8d, %rsi
subl %ecx, %r8d
leaq (%rax,%rsi,4), %rax
movslq %r8d, %rcx
leaq (%rdx,%rcx,4), %rcx
cmovlq %rax, %rcx
movslq (%rcx), %r15
movq 0x48(%rsp), %r13
movq 0x90(%rbx), %rdx
leaq (%r15,%r15,2), %rsi
movq (%rdx,%rsi,8), %rcx
movq 0x8(%rdx,%rsi,8), %rax
cmpq %rax, %rcx
leaq 0x8(%rsp), %r15
je 0x5667
leaq (%rdx,%rsi,8), %r14
movq %rcx, %rdx
cmpl %r12d, (%rdx)
jne 0x5623
addq $0x4, %rdx
cmpq %rax, %rdx
jne 0x55ea
jmp 0x5667
movq 0xb9cf(%rip), %rax      # 0x10fd0
movq (%rax), %rcx
movl $0x1b, %esi
movl $0x1, %edx
leaq 0x6fee(%rip), %rdi      # 0xc603
callq 0x2240
movq (%r14), %rcx
movq 0x8(%r14), %rax
jmp 0x562c
movq 0x8(%r14), %rax
cmpq %rax, %rcx
je 0x55fa
subq %rcx, %rax
shrq $0x2, %rax
decl %eax
movl $0x0, 0x10(%rsp)
movl %eax, 0x14(%rsp)
movq %rbp, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x5a56
movq (%r14), %rcx
cltq
movl (%rcx,%rax,4), %edx
cmpl %r12d, %edx
je 0x5623
movq %rbx, %rdi
movl %r12d, %esi
callq 0x2930
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x5676
callq 0x2150
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
movq 0x40(%rsp), %r14
je 0x568a
callq 0x2150
movq %r15, %rdi
callq 0x5daa
movsd 0x20(%r13), %xmm1
ucomisd %xmm0, %xmm1
ja 0x536a
jmp 0x5709
movq 0xb925(%rip), %rax      # 0x10fd0
movq (%rax), %rcx
movl $0x1b, %esi
movl $0x1, %edx
leaq 0x6f44(%rip), %rdi      # 0xc603
callq 0x2240
movq (%r14), %rcx
movq 0x8(%r14), %rax
jmp 0x54ab
movq 0xb8f9(%rip), %rax      # 0x10fd0
movq (%rax), %rcx
movl $0x22, %esi
movl $0x1, %edx
leaq 0x6ef5(%rip), %rdi      # 0xc5e0
movl %r8d, %r14d
callq 0x2240
movl %r14d, %r8d
movq (%r15), %rax
movq 0x8(%r15), %rcx
movq (%r13), %rdx
subq %rax, %rcx
jmp 0x55a0
movq 0x70(%rsp), %rsi
addq $0x4, %rsi
cmpq 0x68(%rsp), %rsi
movq 0x18(%rsp), %rdi
jne 0x52fb
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5740
jmp 0x5740
jmp 0x5740
jmp 0x5740
jmp 0x5740
jmp 0x5740
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x5752
callq 0x2150
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x5761
callq 0x2150
movq %rbx, %rdi
callq 0x2220
nop