// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x88, %rsp
leaq 0x1e46(%rip), %rdi      # 0x3004
leaq 0x84(%rsp), %rsi
leaq 0x80(%rsp), %rdx
movb $0x0, %al
callq 0x1090
movl 0x84(%rsp), %esi
movl 0x80(%rsp), %edx
leaq 0x1e24(%rip), %rdi      # 0x300e
movb $0x0, %al
callq 0x1040
movslq 0x80(%rsp), %rdi
callq 0x2160
movq %rax, 0x78(%rsp)
movslq 0x80(%rsp), %rdi
shlq $0x0, %rdi
callq 0x1070
movq %rax, 0x70(%rsp)
movl $0x0, 0x6c(%rsp)
movl 0x6c(%rsp), %eax
cmpl 0x80(%rsp), %eax
jge 0x1249
movq 0x70(%rsp), %rax
movslq 0x6c(%rsp), %rcx
movb $0x0, (%rax,%rcx)
movl 0x6c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x6c(%rsp)
jmp 0x1221
movl $0x1efcb35, %edi        # imm = 0x1EFCB35
callq 0x1050
movl $0x0, 0x68(%rsp)
movl 0x68(%rsp), %eax
cmpl 0x84(%rsp), %eax
jge 0x1635
callq 0x10a0
movl $0x9, %ecx
cltd
idivl %ecx
movl %edx, 0x64(%rsp)
cmpl $0x5, 0x64(%rsp)
jle 0x128c
movl $0x1, 0x64(%rsp)
cmpl $0x0, 0x64(%rsp)
jne 0x12f3
callq 0x10a0
cltd
idivl 0x80(%rsp)
movl %edx, 0x60(%rsp)
callq 0x10a0
cltd
idivl 0x80(%rsp)
movl %edx, 0x5c(%rsp)
movq 0x78(%rsp), %rdi
movslq 0x60(%rsp), %rsi
movslq 0x5c(%rsp), %rdx
callq 0x27e0
movl 0x64(%rsp), %esi
movl 0x60(%rsp), %edx
movl 0x5c(%rsp), %ecx
leaq 0x1d2e(%rip), %rdi      # 0x300a
movb $0x0, %al
callq 0x1040
movl 0x68(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x68(%rsp)
jmp 0x1630
cmpl $0x1, 0x64(%rsp)
jne 0x142b
callq 0x10a0
cltd
idivl 0x80(%rsp)
movl %edx, 0x58(%rsp)
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
cmpl 0x80(%rsp), %eax
jge 0x1426
movq 0x70(%rsp), %rax
movq %rax, 0x20(%rsp)
movl 0x54(%rsp), %eax
addl 0x58(%rsp), %eax
cltd
idivl 0x80(%rsp)
movq 0x20(%rsp), %rax
movslq %edx, %rcx
testb $0x1, (%rax,%rcx)
jne 0x1414
movl 0x54(%rsp), %eax
addl 0x58(%rsp), %eax
cltd
idivl 0x80(%rsp)
cmpl $0x0, %edx
jne 0x136e
jmp 0x1416
callq 0x10a0
movl %eax, 0x14(%rsp)
movl 0x54(%rsp), %eax
addl 0x58(%rsp), %eax
cltd
idivl 0x80(%rsp)
movl 0x14(%rsp), %eax
movl %edx, %ecx
cltd
idivl %ecx
movslq %edx, %rax
movq %rax, 0x48(%rsp)
movq 0x78(%rsp), %rdi
movl 0x54(%rsp), %eax
addl 0x58(%rsp), %eax
cltd
idivl 0x80(%rsp)
movslq %edx, %rsi
movq 0x48(%rsp), %rdx
callq 0x25d0
movq 0x70(%rsp), %rax
movq %rax, 0x18(%rsp)
movl 0x54(%rsp), %eax
addl 0x58(%rsp), %eax
cltd
idivl 0x80(%rsp)
movq 0x18(%rsp), %rax
movslq %edx, %rcx
movb $0x1, (%rax,%rcx)
movl 0x64(%rsp), %esi
movl 0x54(%rsp), %eax
addl 0x58(%rsp), %eax
cltd
idivl 0x80(%rsp)
movq 0x48(%rsp), %rcx
leaq 0x1c16(%rip), %rdi      # 0x3016
movb $0x0, %al
callq 0x1040
movl 0x68(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x68(%rsp)
jmp 0x1426
jmp 0x1416
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x1317
jmp 0x162e
cmpl $0x2, 0x64(%rsp)
jne 0x1511
callq 0x10a0
cltd
idivl 0x80(%rsp)
movl %edx, 0x44(%rsp)
movl $0x0, 0x40(%rsp)
movl 0x40(%rsp), %eax
cmpl 0x80(%rsp), %eax
jge 0x150c
movq 0x70(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0x40(%rsp), %eax
addl 0x44(%rsp), %eax
cltd
idivl 0x80(%rsp)
movq 0x8(%rsp), %rax
movslq %edx, %rcx
testb $0x1, (%rax,%rcx)
je 0x14fa
movq 0x78(%rsp), %rdi
movl 0x40(%rsp), %eax
addl 0x44(%rsp), %eax
cltd
idivl 0x80(%rsp)
movslq %edx, %rsi
callq 0x2480
movq 0x70(%rsp), %rax
movq %rax, (%rsp)
movl 0x40(%rsp), %eax
addl 0x44(%rsp), %eax
cltd
idivl 0x80(%rsp)
movq (%rsp), %rax
movslq %edx, %rcx
movb $0x0, (%rax,%rcx)
movl 0x64(%rsp), %esi
movl 0x40(%rsp), %eax
addl 0x44(%rsp), %eax
cltd
idivl 0x80(%rsp)
leaq 0x1b26(%rip), %rdi      # 0x300a
xorl %ecx, %ecx
movb $0x0, %al
callq 0x1040
movl 0x68(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x68(%rsp)
jmp 0x150c
jmp 0x14fc
movl 0x40(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x40(%rsp)
jmp 0x144f
jmp 0x162c
cmpl $0x3, 0x64(%rsp)
jne 0x1560
callq 0x10a0
cltd
idivl 0x80(%rsp)
movl %edx, 0x3c(%rsp)
movq 0x78(%rsp), %rdi
movslq 0x3c(%rsp), %rsi
callq 0x2930
movl 0x64(%rsp), %esi
movl 0x3c(%rsp), %edx
leaq 0x1ac3(%rip), %rdi      # 0x300a
xorl %ecx, %ecx
movb $0x0, %al
callq 0x1040
movl 0x68(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x68(%rsp)
jmp 0x162a
cmpl $0x4, 0x64(%rsp)
jne 0x15c4
callq 0x10a0
cltd
idivl 0x80(%rsp)
movl %edx, 0x38(%rsp)
callq 0x10a0
movl $0xf4240, %ecx          # imm = 0xF4240
cltd
idivl %ecx
movl %edx, 0x34(%rsp)
movq 0x78(%rsp), %rdi
movslq 0x38(%rsp), %rsi
movslq 0x34(%rsp), %rdx
callq 0x2880
movl 0x64(%rsp), %esi
movl 0x38(%rsp), %edx
movl 0x34(%rsp), %ecx
leaq 0x1a5a(%rip), %rdi      # 0x300a
movb $0x0, %al
callq 0x1040
movl 0x68(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x68(%rsp)
jmp 0x1628
cmpl $0x5, 0x64(%rsp)
jne 0x1626
callq 0x10a0
cltd
idivl 0x80(%rsp)
movl %edx, 0x30(%rsp)
callq 0x10a0
movl $0x186a0, %ecx          # imm = 0x186A0
cltd
idivl %ecx
movl %edx, 0x2c(%rsp)
movq 0x78(%rsp), %rdi
movslq 0x30(%rsp), %rsi
movslq 0x2c(%rsp), %rdx
callq 0x28c0
movl 0x64(%rsp), %esi
movl 0x30(%rsp), %edx
movl 0x2c(%rsp), %ecx
leaq 0x19f6(%rip), %rdi      # 0x300a
movb $0x0, %al
callq 0x1040
movl 0x68(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x68(%rsp)
jmp 0x1628
jmp 0x162a
jmp 0x162c
jmp 0x162e
jmp 0x1630
jmp 0x125b
addq $0x88, %rsp
retq
nopl (%rax)