// File: /workspace/github_c_makefile_star2_O2/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 0xe6e(%rip), %rdi       # 0x201c
xorl %r12d, %r12d
leaq 0x4(%rsp), %rbx
movq %rsp, %r14
movq %rbx, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1080
movl (%rbx), %esi
movl (%r14), %edx
leaq 0xe54(%rip), %rdi       # 0x2026
xorl %eax, %eax
callq 0x1040
movslq (%r14), %rdi
callq 0x1958
movq %rax, %rbx
movslq (%r14), %r15
movq %r15, %rdi
callq 0x1060
movq %rax, %r14
movl %r15d, %eax
sarl $0x1f, %eax
andnl %r15d, %eax, %eax
cmpq %r12, %rax
je 0x120c
movb $0x0, (%r14,%r12)
incq %r12
jmp 0x11fd
movl $0x1efcb35, %edi        # imm = 0x1EFCB35
callq 0x1050
leaq 0xde7(%rip), %r15       # 0x2004
xorl %ebp, %ebp
cmpl 0x4(%rsp), %ebp
jge 0x142f
callq 0x1090
cltd
pushq $0x9
popq %rcx
idivl %ecx
cmpl $0x6, %edx
pushq $0x1
popq %rax
cmovgel %eax, %edx
cmpl $0x5, %edx
ja 0x121f
movslq (%r15,%rdx,4), %rax
addq %r15, %rax
jmpq *%rax
callq 0x1090
cltd
idivl (%rsp)
movl %edx, %r12d
callq 0x1090
cltd
idivl (%rsp)
movslq %r12d, %r12
movslq %edx, %r13
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1ca1
leaq 0xda7(%rip), %rdi       # 0x2022
xorl %esi, %esi
jmp 0x141b
callq 0x1090
cltd
idivl (%rsp)
movl %edx, %r12d
callq 0x1090
cltd
movl $0xf4240, %ecx          # imm = 0xF4240
idivl %ecx
movslq %r12d, %r12
movslq %edx, %r13
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1cf8
leaq 0xd6c(%rip), %rdi       # 0x2022
pushq $0x4
jmp 0x141a
callq 0x1090
movl (%rsp), %edi
cltd
idivl %edi
movl %edx, %r12d
movl %edi, %eax
sarl $0x1f, %eax
andnl %edi, %eax, %r8d
negl %r8d
xorl %r13d, %r13d
movl %edx, %ecx
cmpl %r13d, %r8d
je 0x121f
movl %ecx, %eax
cltd
idivl %edi
movslq %edx, %rsi
decl %r13d
incl %ecx
cmpb $0x1, (%r14,%rsi)
jne 0x12dd
movq %rbx, %rdi
callq 0x1ae6
notl %r13d
addl %r12d, %r13d
movl %r13d, %eax
cltd
idivl (%rsp)
movslq %edx, %rdx
movb $0x0, (%r14,%rdx)
leaq 0xd04(%rip), %rdi       # 0x2022
pushq $0x2
popq %rsi
jmp 0x1347
callq 0x1090
cltd
idivl (%rsp)
movslq %edx, %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1d20
leaq 0xce1(%rip), %rdi       # 0x2022
pushq $0x3
popq %rsi
movl %r12d, %edx
xorl %ecx, %ecx
jmp 0x1421
callq 0x1090
movl (%rsp), %esi
cltd
idivl %esi
movl %edx, %r12d
movl %esi, %eax
sarl $0x1f, %eax
andnl %esi, %eax, %edi
negl %edi
xorl %r13d, %r13d
movl %edx, %ecx
cmpl %r13d, %edi
je 0x121f
movl %ecx, %eax
cltd
idivl %esi
decl %r13d
incl %ecx
testl %edx, %edx
je 0x136d
movslq %edx, %rax
cmpb $0x0, (%r14,%rax)
jne 0x136d
callq 0x1090
movl %eax, %ecx
notl %r13d
addl %r12d, %r13d
movl %r13d, %eax
cltd
idivl (%rsp)
movl %edx, %esi
movl %ecx, %eax
cltd
idivl %esi
movslq %edx, %r12
movslq %esi, %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0x1b87
movl %r13d, %eax
cltd
idivl (%rsp)
movslq %edx, %rdx
movb $0x1, (%r14,%rdx)
leaq 0xc5e(%rip), %rdi       # 0x202e
pushq $0x1
popq %rsi
movq %r12, %rcx
xorl %eax, %eax
callq 0x1040
incl %ebp
jmp 0x121f
callq 0x1090
cltd
idivl (%rsp)
movl %edx, %r12d
callq 0x1090
cltd
movl $0x186a0, %ecx          # imm = 0x186A0
idivl %ecx
movslq %r12d, %r12
movslq %edx, %r13
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1d0b
leaq 0xc0a(%rip), %rdi       # 0x2022
pushq $0x5
popq %rsi
movl %r12d, %edx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x1040
incl %ebp
jmp 0x121f
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq