// File: /workspace/github_c_makefile_star2_O2/6851-2021[P]euler_tour_tree/euler_tour_tree_test.c
// Function: main
int main() {
    int n = 10000;
    EulerTourTree* tree = make_euler_tour_tree(n);
    EulerTourTreeTest* tree_test = make_euler_tour_tree_test(n);
    srand(32492341);
    for (int i = 0; i < 1000; i++) {
        int op = rand() % 9;

        if (op > 5) {
            op = 1;
        }

        // scanf("%d\n", &op);
        if (op == 0) {
            for (int i = 0; i < n; i++) {
                assert(find_root(tree, i) == find_root_test(tree_test, i));
            }
        } else if (op == 1) {
            int i = rand() % n;
            for (int j = 0; j < n; j++) {
                if ((j+i)%n != 0 && tree_test->parent[(j+i)%n] == -1) {
                    k_t par = rand() % ((j+i)%n);
                    link(tree, (j+i)%n, par);
                    link_test(tree_test, (j+i)%n, par);
                    break;
                }
            }
        } else if (op == 2) {
            int i = rand() % n;
            for (int j = 0; j < n; j++) {
                if (tree_test->parent[(j+i)%n] != -1) {
                    cut(tree, (j+i)%n);
                    cut_test(tree_test, (j+i)%n);
                    break;
                }
            }
        } else if (op == 3) {
            for (int i = 0; i < n; i++) {
                assert(subtree_aggregate_min(tree, i) == subtree_aggregate_min_test(tree_test, i));
                assert(subtree_aggregate_max(tree, i) == subtree_aggregate_max_test(tree_test, i));
                assert(subtree_aggregate_sum(tree, i) == subtree_aggregate_sum_test(tree_test, i));
                assert(subtree_aggregate_size(tree, i) == subtree_aggregate_size_test(tree_test, i));
            }
        } else if (op == 4) {
            int v = rand() % n;
            int val = rand() % 1000000;
            point_update(tree, v, val);
            point_update_test(tree_test, v, val);
        } else if (op == 5) {
            int v = rand() % n;
            int val = rand() % 100000;
            subtree_update(tree, v, val);
            subtree_update_test(tree_test, v, val);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl $0x2710, %edi           # imm = 0x2710
callq 0x16ac
movq %rax, %rbx
movl $0x2710, %edi           # imm = 0x2710
callq 0x1b30
movq %rax, %r14
movl $0x1efcb35, %edi        # imm = 0x1EFCB35
callq 0x1060
xorl %r13d, %r13d
movl $0x2710, %ebp           # imm = 0x2710
cmpl $0x3e8, %r13d           # imm = 0x3E8
je 0x200d
callq 0x1090
cltd
pushq $0x9
popq %rcx
idivl %ecx
cmpl $0x6, %edx
pushq $0x1
popq %rax
cmovgel %eax, %edx
cmpl $0x5, %edx
ja 0x2005
leaq 0x1227(%rip), %rcx      # 0x3044
movslq (%rcx,%rdx,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %r15d, %r15d
cmpq $0x2710, %r15           # imm = 0x2710
je 0x2005
movq %rbx, %rdi
movq %r15, %rsi
callq 0x180f
movq %rax, %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x1bb2
incq %r15
cmpq %rax, %r12
je 0x1e29
jmp 0x201e
callq 0x1090
cltd
idivl %ebp
movl %edx, %r15d
callq 0x1090
cltd
movl $0xf4240, %ecx          # imm = 0xF4240
idivl %ecx
movslq %r15d, %r15
movslq %edx, %r12
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1a4c
movq 0x8(%r14), %rax
movq %r12, (%rax,%r15,8)
jmp 0x2005
callq 0x1090
cltd
idivl %ebp
movl %edx, %ecx
movq (%r14), %r12
xorl %esi, %esi
cmpl $0x2710, %esi           # imm = 0x2710
je 0x2005
leal (%rcx,%rsi), %eax
cltd
idivl %ebp
movslq %edx, %r15
incl %esi
cmpq $-0x1, (%r12,%r15,8)
je 0x1ea4
movq %rbx, %rdi
movq %r15, %rsi
callq 0x183a
orq $-0x1, (%r12,%r15,8)
jmp 0x2005
xorl %r15d, %r15d
cmpq $0x2710, %r15           # imm = 0x2710
je 0x2005
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1a74
movq %rax, %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x1c51
cmpq %rax, %r12
jne 0x209a
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1aa2
movq %rax, %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x1cad
cmpq %rax, %r12
jne 0x207b
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1ad1
movq %rax, %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x1d09
cmpq %rax, %r12
jne 0x205c
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1b00
movq %rax, %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x1d61
incq %r15
cmpq %rax, %r12
je 0x1eda
jmp 0x203d
callq 0x1090
cltd
idivl %ebp
movl %edx, %ecx
xorl %esi, %esi
cmpl $0x2710, %esi           # imm = 0x2710
je 0x2005
leal (%rcx,%rsi), %eax
cltd
idivl %ebp
testl %edx, %edx
je 0x1fa2
movq (%r14), %r12
movslq %edx, %r15
cmpq $-0x1, (%r12,%r15,8)
je 0x1fe2
incl %esi
jmp 0x1f83
callq 0x1090
cltd
idivl %ebp
movl %edx, %r15d
callq 0x1090
cltd
movl $0x186a0, %ecx          # imm = 0x186A0
idivl %ecx
movslq %r15d, %r15
movslq %edx, %r12
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1a5f
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1c07
jmp 0x2005
callq 0x1090
cltd
idivl %r15d
movslq %edx, %rdx
movq %rdx, (%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x18db
movq (%rsp), %rax
movq %rax, (%r12,%r15,8)
incl %r13d
jmp 0x1dec
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1037(%rip), %rdi      # 0x305c
leaq 0x1063(%rip), %rsi      # 0x308f
leaq 0x1073(%rip), %rcx      # 0x30a6
movl $0x88, %edx
callq 0x1050
leaq 0x114e(%rip), %rdi      # 0x3192
leaq 0x1044(%rip), %rsi      # 0x308f
leaq 0x1054(%rip), %rcx      # 0x30a6
movl $0xa2, %edx
callq 0x1050
leaq 0x10e4(%rip), %rdi      # 0x3147
leaq 0x1025(%rip), %rsi      # 0x308f
leaq 0x1035(%rip), %rcx      # 0x30a6
movl $0xa1, %edx
callq 0x1050
leaq 0x107a(%rip), %rdi      # 0x30fc
leaq 0x1006(%rip), %rsi      # 0x308f
leaq 0x1016(%rip), %rcx      # 0x30a6
movl $0xa0, %edx
callq 0x1050
leaq 0x1010(%rip), %rdi      # 0x30b1
leaq 0xfe7(%rip), %rsi       # 0x308f
leaq 0xff7(%rip), %rcx       # 0x30a6
movl $0x9f, %edx
callq 0x1050