// File: /workspace/github_cpp_makefile_star2_O2/patmorin[P]rotate/rotatetest.cpp
// Function: main
int main(int argc, char *argv[]) {
    Index n, r;

    if (argc != 3) usage(argv[0]);
    std::istringstream is_n(argv[1]);
    is_n >> n;
    std::istringstream is_r(argv[2]);
    is_r >> r;

    std::cout << "n = " << n << ", r = " << r << std::endl;

		auto *a = new Data[n];

		Rotater fns[] =
		{ rotate_std<Data,Index>, rotate_stdrev<Data,Index>,
			rotate_rev<Data,Index>, rotate_gcd<Data,Index> };
		std::string fn_names[] =
		{ "rotate_std", "rotate_stdrev", "rotate_rev", "rotate_gcd" };

		if (n <= 50) {
			for (int i = 0; i < 4; i++) {
				std::iota(a, a+n, 1);
				print_array(a, n);
				rotate_std(a, n, r);
				print_array(a, n);
				std::cout << std::endl;
			}
		} else {
			for (int i = 0; i < 4; i++) {
		    std::iota(a, a+n, 1);

				std::cout << std::setw(20) << fn_names[i] << " : ";
		    speed_test(a, n, r, fns[i]);
			}
		}
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3a8, %rsp            # imm = 0x3A8
movq %rsi, %rbx
cmpl $0x3, %edi
jne 0x1565
movq 0x8(%rbx), %rsi
leaq 0xa8(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x1050
leaq 0x228(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
pushq $0x8
popq %rdx
callq 0x1120
leaq 0xa8(%rsp), %rdi
callq 0x1060
leaq 0x228(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1090
movq 0x10(%rbx), %rsi
leaq 0x20(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x1050
leaq 0xa8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
pushq $0x8
popq %rdx
callq 0x1120
leaq 0x20(%rsp), %rdi
callq 0x1060
leaq 0xa8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x1090
movq 0x2c6e(%rip), %r14      # 0x3fd0
leaq 0xcb8(%rip), %rsi       # 0x2021
movq %r14, %rdi
callq 0x10d0
movq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x10a0
leaq 0xca1(%rip), %rsi       # 0x2026
movq %rax, %rdi
callq 0x10d0
movq 0x18(%rsp), %rsi
movq %rax, %rdi
callq 0x10a0
movq %rax, %rdi
callq 0x1080
movq 0x8(%rsp), %rax
movq %rax, %rcx
shrq $0x3e, %rcx
shlq $0x2, %rax
negq %rcx
sbbq %rdi, %rdi
orq %rax, %rdi
callq 0x1030
leaq 0x20(%rsp), %r15
leaq 0xc61(%rip), %rsi       # 0x202d
leaq 0x7(%rsp), %rdx
movq %rax, %rbx
movq %r15, %rdi
callq 0x1050
leaq 0x40(%rsp), %r12
leaq 0xc50(%rip), %rsi       # 0x2038
leaq 0x17(%rsp), %rdx
movq %r12, %rdi
callq 0x1050
leaq 0x60(%rsp), %r12
leaq 0xc45(%rip), %rsi       # 0x2046
leaq 0x16(%rsp), %rdx
movq %r12, %rdi
callq 0x1050
leaq 0x80(%rsp), %r12
leaq 0xc34(%rip), %rsi       # 0x2051
leaq 0x15(%rsp), %rdx
movq %r12, %rdi
callq 0x1050
cmpq $0x33, 0x8(%rsp)
jae 0x149e
xorl %r15d, %r15d
pushq $0x1
popq %rbp
movq 0x2b91(%rip), %r14      # 0x3fd0
cmpl $0x4, %r15d
je 0x1520
movq 0x8(%rsp), %rsi
xorl %ecx, %ecx
movl %ebp, %edx
leaq (,%rsi,4), %rax
cmpq %rcx, %rax
je 0x146a
movl %edx, (%rbx,%rcx)
incl %edx
addq $0x4, %rcx
jmp 0x145a
movq %rbx, %rdi
callq 0x16e8
movq 0x18(%rsp), %rdx
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x15fc
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x16e8
movq %r14, %rdi
callq 0x1080
incl %r15d
jmp 0x143f
xorl %r12d, %r12d
pushq $0x1
popq %rbp
leaq 0xbb1(%rip), %r15       # 0x205c
leaq 0x28de(%rip), %r13      # 0x3d90
cmpq $0x4, %r12
je 0x1520
movq 0x8(%rsp), %rax
xorl %ecx, %ecx
movl %ebp, %edx
shlq $0x2, %rax
cmpq %rcx, %rax
je 0x14d5
movl %edx, (%rbx,%rcx)
incl %edx
addq $0x4, %rcx
jmp 0x14c5
movq (%r14), %rax
movq -0x18(%rax), %rax
movq $0x14, 0x10(%r14,%rax)
movq %r12, %rax
shlq $0x5, %rax
leaq 0x20(%rsp,%rax), %rsi
movq %r14, %rdi
callq 0x10c0
movq %rax, %rdi
movq %r15, %rsi
callq 0x10d0
movq 0x18(%rsp), %rdx
movq 0x8(%rsp), %rsi
movq (%r13,%r12,8), %rcx
movq %rbx, %rdi
callq 0x175c
incq %r12
jmp 0x14b2
pushq $0x60
popq %rbx
leaq 0x20(%rsp,%rbx), %rdi
callq 0x1060
addq $-0x20, %rbx
cmpq $-0x20, %rbx
jne 0x1523
leaq 0xa8(%rsp), %rdi
callq 0x1070
leaq 0x228(%rsp), %rdi
callq 0x1070
xorl %eax, %eax
addq $0x3a8, %rsp            # imm = 0x3A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx), %rdi
callq 0x126c
jmp 0x1571
jmp 0x1571
movq %rax, %rbx
addq $-0x20, %r12
movq %r12, %rdi
callq 0x1060
cmpq %r15, %r12
jne 0x1574
jmp 0x15da
jmp 0x15b8
jmp 0x15b8
leaq 0x20(%rsp), %rdi
movq %rax, %rbx
callq 0x1060
jmp 0x15e7
jmp 0x159c
movq %rax, %rbx
jmp 0x15e7
leaq 0xa8(%rsp), %rdi
movq %rax, %rbx
callq 0x1060
jmp 0x15f4
movq %rax, %rbx
jmp 0x15f4
movq %rax, %rbx
jmp 0x15da
jmp 0x15bf
movq %rax, %rbx
pushq $0x60
popq %r14
leaq 0x20(%rsp,%r14), %rdi
callq 0x1060
addq $-0x20, %r14
cmpq $-0x20, %r14
jne 0x15c6
leaq 0xa8(%rsp), %rdi
callq 0x1070
leaq 0x228(%rsp), %rdi
callq 0x1070
movq %rbx, %rdi
callq 0x1130