// File: /workspace/github_c_makefile_star2_O1/6851-2021[P]euler_tour_tree/benchmark_gen.c
// Function: test_gen
void test_gen() {
    int ops, n;
    scanf("%d %d", &ops, &n);
    printf("%d, %d\n", ops, n);

    EulerTourTree* tree = make_euler_tour_tree(n);

    bool* has_parent = malloc(sizeof(bool) * n);
    for (int i = 0; i < n; ++i) {
        has_parent[i] = false;
    }
    srand(32492341);

    for (int rounds = 0; rounds < ops;) {
        int op = rand() % 9;

        // Weight probability of link higher, to create a denser ETT
        if (op > 5) {
            op = 1;
        }

        // Test for connectivity
        if (op == 0) {
            int i = rand() % n;
            int j = rand() % n;
            connectivity(tree, i, j);
            printf("%d, %d, %d\n", op, i, j);
            rounds++;
        // Perform a link
        } else if (op == 1) {
            int i = rand() % n;
            for (int j = 0; j < n; j++) {
                if (!has_parent[(j+i)%n]) {
                    if ((j+i) % n == 0) continue;
                    k_t par = rand() % ((j+i) % n);
                    link(tree, (j+i)%n, par);
                    has_parent[(j+i) % n] = true;
                    printf("%d, %d, %ld\n", op, (j+i)%n, par);
                    rounds++;
                    break;
                }
            }
        // Perform a cut
        } else if (op == 2) {
            int i = rand() % n;
            for (int j = 0; j < n; j++) {
                if (has_parent[(j+i)%n]) {
                    cut(tree, (j+i)%n);
                    has_parent[(j+i)%n] = false;
                    printf("%d, %d, %d\n", op, (j+i)%n, 0);
                    rounds++;
                    break;
                }
            }
        // Perform a subtree_aggregate
        } else if (op == 3) {
            int i = rand() % n;
            subtree_aggregate_min(tree, i);
            printf("%d, %d, %d\n", op, i, 0);
            rounds++;
            // subtree_aggregate_max(tree, i);
            // subtree_aggregate_sum(tree, i);
            // subtree_aggregate_size(tree, i);
        
        // Perform a point update, setting a node to a new value
        } else if (op == 4) {
            int v = rand() % n;
            int val = rand() % 1000000;
            point_update(tree, v, val);
            printf("%d, %d, %d\n", op, v, val);
            rounds++;
        // Perform a subtree update, incrementing all nodes in a subtree by a value val
        } else if (op == 5) {
            int v = rand() % n;
            int val = rand() % 100000;
            subtree_update(tree, v, val);
            printf("%d, %d, %d\n", op, v, val);
            rounds++;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0xe5e(%rip), %rdi       # 0x201c
leaq 0x4(%rsp), %rbx
movq %rsp, %r14
movq %rbx, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1090
movl (%rbx), %esi
movl (%r14), %edx
leaq 0xe47(%rip), %rdi       # 0x2026
xorl %eax, %eax
callq 0x1040
movslq (%r14), %rdi
callq 0x19b8
movq %rax, %rbx
movslq (%r14), %r15
movq %r15, %rdi
callq 0x1070
movq %rax, %r14
testq %r15, %r15
jle 0x1211
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x1050
movl $0x1efcb35, %edi        # imm = 0x1EFCB35
callq 0x1060
cmpl $0x0, 0x4(%rsp)
jle 0x1474
leaq 0xdd7(%rip), %r15       # 0x2004
xorl %r12d, %r12d
callq 0x10a0
cltq
imulq $0x38e38e39, %rax, %rcx # imm = 0x38E38E39
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x21, %rcx
addl %edx, %ecx
leal (%rcx,%rcx,8), %ecx
subl %ecx, %eax
cmpl $0x6, %eax
movl $0x1, %ecx
cmovgel %ecx, %eax
cmpl $0x5, %eax
ja 0x141c
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
callq 0x10a0
cltd
idivl (%rsp)
movl %edx, %ebp
callq 0x10a0
cltd
idivl (%rsp)
movslq %ebp, %r13
movslq %edx, %rbp
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x1d09
leaq 0xd86(%rip), %rdi       # 0x2022
xorl %esi, %esi
jmp 0x13e7
callq 0x10a0
cltd
idivl (%rsp)
movl %edx, %ebp
callq 0x10a0
cltq
imulq $0x431bde83, %rax, %rcx # imm = 0x431BDE83
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x32, %rcx
addl %edx, %ecx
imull $0xf4240, %ecx, %ecx    # imm = 0xF4240
subl %ecx, %eax
movslq %ebp, %r13
movslq %eax, %rbp
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x1d60
leaq 0xd36(%rip), %rdi       # 0x2022
movl $0x4, %esi
jmp 0x13e7
callq 0x10a0
movl (%rsp), %edi
cltd
idivl %edi
testl %edi, %edi
jle 0x141c
movl %edx, %ecx
xorl %r8d, %r8d
leal (%rcx,%r8), %ebp
movl %ebp, %eax
cltd
idivl %edi
movslq %edx, %rsi
cmpb $0x1, (%r14,%rsi)
je 0x13ee
incl %r8d
cmpl %r8d, %edi
jne 0x130e
jmp 0x141c
callq 0x10a0
cltd
idivl (%rsp)
movslq %edx, %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1d88
leaq 0xcd2(%rip), %rdi       # 0x2022
movl $0x3, %esi
movl %r13d, %edx
jmp 0x1410
callq 0x10a0
movl (%rsp), %esi
cltd
idivl %esi
testl %esi, %esi
jle 0x141c
movl %edx, %ecx
xorl %edi, %edi
leal (%rcx,%rdi), %ebp
movl %ebp, %eax
cltd
idivl %esi
testl %edx, %edx
je 0x138e
movslq %edx, %rax
cmpb $0x0, (%r14,%rax)
je 0x1429
incl %edi
cmpl %edi, %esi
jne 0x1374
jmp 0x141c
callq 0x10a0
cltd
idivl (%rsp)
movl %edx, %ebp
callq 0x10a0
cltq
imulq $0x14f8b589, %rax, %rcx # imm = 0x14F8B589
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x2d, %rcx
addl %edx, %ecx
imull $0x186a0, %ecx, %ecx    # imm = 0x186A0
subl %ecx, %eax
movslq %ebp, %r13
movslq %eax, %rbp
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x1d73
leaq 0xc40(%rip), %rdi       # 0x2022
movl $0x5, %esi
movl %r13d, %edx
movl %ebp, %ecx
jmp 0x1412
movq %rbx, %rdi
callq 0x1b4d
movl %ebp, %eax
cltd
idivl (%rsp)
movslq %edx, %rdx
movb $0x0, (%r14,%rdx)
leaq 0xc17(%rip), %rdi       # 0x2022
movl $0x2, %esi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x1040
incl %r12d
cmpl 0x4(%rsp), %r12d
jl 0x1230
jmp 0x1474
callq 0x10a0
movl %eax, %ecx
movl %ebp, %eax
cltd
idivl (%rsp)
movl %edx, %esi
movl %ecx, %eax
cltd
idivl %esi
movslq %edx, %r13
movslq %esi, %rsi
movq %rbx, %rdi
movq %r13, %rdx
callq 0x1bf3
movl %ebp, %eax
cltd
idivl (%rsp)
movslq %edx, %rdx
movb $0x1, (%r14,%rdx)
leaq 0xbcb(%rip), %rdi       # 0x202e
movl $0x1, %esi
movq %r13, %rcx
xorl %eax, %eax
callq 0x1040
jmp 0x1419
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq