// File: canzarlab[P]Trajan/src/generator.cpp
// Function: uniform(int)
newick_node* uniform(int n)
{
    unsigned random[n], size = 2;
    iota(random, random + n, 1);
    random_shuffle(random, random + n);

    newick_node* leaf1 = new newick_node(to_string(random[0]));
    newick_node* leaf2 = new newick_node(to_string(random[1]));
    newick_child* child = new newick_child(leaf1);
    child->next = new newick_child(leaf2);

    newick_node* root = new newick_node("", 0, child);
    vector<pair<newick_node*, newick_node*>> E;
    E.emplace_back(root, leaf1);
    E.emplace_back(root, leaf2);

    for (int k = 0; k < n - 2; k++)
    {
        int i = rand() % E.size();
        leaf1 = new newick_node(to_string(random[size++]));
        leaf2 = new newick_node("", 0, new newick_child(E[i].second));
        leaf2->child->next = new newick_child(leaf1);

        newick_child* pchild = E[i].first->child;
        if (pchild->node == E[i].second)
            pchild->node = leaf2;
        else
            pchild->next->node = leaf2;

        E.emplace_back(leaf2, leaf1);
        E.emplace_back(leaf2, E[i].second);
        E[i].second = leaf2;
    }
    return root;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
movl %edi, -0x4(%rbp)
movl -0x4(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x10(%rbp)
leaq 0xf(,%rax,4), %rcx
andq $-0x10, %rcx
movq %rsp, %rdi
movq %rdi, -0x148(%rbp)
subq %rcx, %rdi
movq %rdi, -0x158(%rbp)
movq %rdi, %rsp
negq %rcx
movq %rcx, -0x150(%rbp)
movq %rax, -0x18(%rbp)
movl $0x2, -0x1c(%rbp)
movslq -0x4(%rbp), %rax
leaq (%rdi,%rax,4), %rsi
movl $0x1, %edx
callq 0x49f0
movq -0x158(%rbp), %rdi
movslq -0x4(%rbp), %rax
leaq (%rdi,%rax,4), %rsi
callq 0x4a30
movl $0x38, %edi
callq 0x32a0
movq -0x150(%rbp), %rcx
movq %rax, %rdx
movq -0x148(%rbp), %rax
movq %rdx, -0x140(%rbp)
movb $0x1, -0x55(%rbp)
movl (%rax,%rcx), %esi
leaq -0x48(%rbp), %rdi
callq 0x4ad0
jmp 0x3c5a
movq -0x140(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq -0x48(%rbp), %rsi
xorps %xmm0, %xmm0
callq 0x6b90
jmp 0x3c73
movb $0x0, -0x55(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x3190
movq -0x140(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x38, %edi
callq 0x32a0
movq %rax, %rcx
movq -0x158(%rbp), %rax
movq %rcx, -0x160(%rbp)
movb $0x1, -0x81(%rbp)
movl 0x4(%rax), %esi
leaq -0x80(%rbp), %rdi
callq 0x4ad0
jmp 0x3cbb
movq -0x160(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq -0x80(%rbp), %rsi
xorps %xmm0, %xmm0
callq 0x6b90
jmp 0x3cd4
movb $0x0, -0x81(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x3190
movq -0x160(%rbp), %rax
movq %rax, -0x60(%rbp)
movl $0x10, %edi
callq 0x32a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x168(%rbp)
movq -0x28(%rbp), %rsi
callq 0x6b20
jmp 0x3d11
movq -0x168(%rbp), %rax
movq %rax, -0x90(%rbp)
movl $0x10, %edi
callq 0x32a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x170(%rbp)
movq -0x60(%rbp), %rsi
callq 0x6b20
jmp 0x3d41
movq -0x170(%rbp), %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x8(%rax)
movl $0x38, %edi
callq 0x32a0
movq %rax, -0x180(%rbp)
movb $0x1, -0xba(%rbp)
leaq -0xb9(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x3460
movq -0x178(%rbp), %rdx
leaq 0xb423(%rip), %rsi      # 0xf1af
leaq -0xb8(%rbp), %rdi
callq 0x4870
jmp 0x3d9a
movq -0x180(%rbp), %rdi
movq -0x90(%rbp), %rdx
leaq -0xb8(%rbp), %rsi
xorps %xmm0, %xmm0
callq 0x6b90
jmp 0x3db9
movb $0x0, -0xba(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x3190
leaq -0xb9(%rbp), %rdi
callq 0x3300
movq -0x180(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0x4c10
movq -0x188(%rbp), %rdi
leaq -0x98(%rbp), %rsi
leaq -0x28(%rbp), %rdx
callq 0x4c30
jmp 0x3e12
leaq -0xd8(%rbp), %rdi
leaq -0x98(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x4c30
jmp 0x3e2b
movl $0x0, -0xdc(%rbp)
movl -0xdc(%rbp), %eax
movl -0x4(%rbp), %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
jge 0x42fc
callq 0x30a0
cltq
movq %rax, -0x198(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x4cb0
movq %rax, %rcx
movq -0x198(%rbp), %rax
xorl %edx, %edx
divq %rcx
movl %edx, %eax
movl %eax, -0xe0(%rbp)
movl $0x38, %edi
callq 0x32a0
movq %rax, -0x190(%rbp)
jmp 0x3e8d
movq -0x158(%rbp), %rax
movb $0x1, -0x101(%rbp)
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
incl %edx
movl %edx, -0x1c(%rbp)
movl (%rax,%rcx,4), %esi
leaq -0x100(%rbp), %rdi
callq 0x4ad0
jmp 0x3eb6
movq -0x190(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq -0x100(%rbp), %rsi
xorps %xmm0, %xmm0
callq 0x6b90
jmp 0x3ed2
movq -0x190(%rbp), %rax
movb $0x0, -0x101(%rbp)
movq %rax, -0x28(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x3190
movl $0x38, %edi
callq 0x32a0
movq %rax, -0x1a0(%rbp)
jmp 0x3f03
movb $0x1, -0x12a(%rbp)
leaq -0x129(%rbp), %rdi
movq %rdi, -0x1a8(%rbp)
callq 0x3460
movq -0x1a8(%rbp), %rdx
leaq 0xb284(%rip), %rsi      # 0xf1af
leaq -0x128(%rbp), %rdi
callq 0x4870
jmp 0x3f39
movl $0x10, %edi
callq 0x32a0
movq %rax, -0x1b0(%rbp)
jmp 0x3f4c
movslq -0xe0(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
callq 0x4cd0
movq -0x1b0(%rbp), %rdi
movq 0x8(%rax), %rsi
callq 0x6b20
jmp 0x3f71
movq -0x1b0(%rbp), %rdx
movq -0x1a0(%rbp), %rdi
leaq -0x128(%rbp), %rsi
xorps %xmm0, %xmm0
callq 0x6b90
jmp 0x3f90
movq -0x1a0(%rbp), %rax
movb $0x0, -0x12a(%rbp)
movq %rax, -0x60(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x3190
leaq -0x129(%rbp), %rdi
callq 0x3300
movl $0x10, %edi
callq 0x32a0
movq %rax, -0x1b8(%rbp)
jmp 0x3fcd
movq -0x1b8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x6b20
jmp 0x3fdf
movq -0x1b8(%rbp), %rcx
movq -0x60(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x8(%rax)
movslq -0xe0(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
callq 0x4cd0
movq (%rax), %rax
movq (%rax), %rax
movq %rax, -0x138(%rbp)
movq -0x138(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x1c0(%rbp)
movslq -0xe0(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
callq 0x4cd0
movq %rax, %rcx
movq -0x1c0(%rbp), %rax
cmpq 0x8(%rcx), %rax
jne 0x4264
movq -0x60(%rbp), %rcx
movq -0x138(%rbp), %rax
movq %rcx, (%rax)
jmp 0x4276
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x407f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x3190
testb $0x1, -0x55(%rbp)
jne 0x4087
jmp 0x4098
movq -0x140(%rbp), %rdi
movl $0x38, %esi
callq 0x32b0
jmp 0x4335
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x40c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x3190
testb $0x1, -0x81(%rbp)
jne 0x40cb
jmp 0x40dc
movq -0x160(%rbp), %rdi
movl $0x38, %esi
callq 0x32b0
jmp 0x4335
movq -0x168(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x10, %esi
callq 0x32b0
jmp 0x4335
movq -0x170(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x10, %esi
callq 0x32b0
jmp 0x4335
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x414b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x3190
leaq -0xb9(%rbp), %rdi
callq 0x3300
testb $0x1, -0xba(%rbp)
jne 0x4162
jmp 0x4173
movq -0x180(%rbp), %rdi
movl $0x38, %esi
callq 0x32b0
jmp 0x4335
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x4329
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x41af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x3190
testb $0x1, -0x101(%rbp)
jne 0x41ba
jmp 0x41cb
movq -0x190(%rbp), %rdi
movl $0x38, %esi
callq 0x32b0
jmp 0x4329
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x4215
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x4209
movq -0x1b0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x10, %esi
callq 0x32b0
leaq -0x128(%rbp), %rdi
callq 0x3190
leaq -0x129(%rbp), %rdi
callq 0x3300
testb $0x1, -0x12a(%rbp)
jne 0x422c
jmp 0x423d
movq -0x1a0(%rbp), %rdi
movl $0x38, %esi
callq 0x32b0
jmp 0x4329
movq -0x1b8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x10, %esi
callq 0x32b0
jmp 0x4329
movq -0x60(%rbp), %rcx
movq -0x138(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, (%rax)
leaq -0xd8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
leaq -0x28(%rbp), %rdx
callq 0x4c30
jmp 0x428c
movslq -0xe0(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x4cd0
movq -0x1c8(%rbp), %rdi
movq %rax, %rdx
addq $0x8, %rdx
leaq -0x60(%rbp), %rsi
callq 0x4c30
jmp 0x42bf
movq -0x60(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movslq -0xe0(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
callq 0x4cd0
movq -0x1d0(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl -0xdc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xdc(%rbp)
jmp 0x3e35
movq -0x98(%rbp), %rax
movq %rax, -0x1d8(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x4cf0
movq -0x1d8(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, %rsp
movq %rbp, %rsp
popq %rbp
retq
leaq -0xd8(%rbp), %rdi
callq 0x4cf0
movq -0x50(%rbp), %rdi
callq 0x3450
nop