// File: /workspace/github_cpp_makefile_star2_O3/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 0x27a8
movq 0x8(%rbx), %rsi
leaq 0xa8(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x2070
leaq 0x228(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
movl $0x8, %edx
callq 0x2180
leaq 0xb8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x238d
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2110
leaq 0x228(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x2090
movq 0x10(%rbx), %rsi
leaq 0x20(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x2070
leaq 0xa8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl $0x8, %edx
callq 0x2180
leaq 0x30(%rsp), %r12
movq -0x10(%r12), %rdi
cmpq %r12, %rdi
je 0x23e5
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2110
leaq 0xa8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x2090
movq 0x2bca(%rip), %rdi      # 0x4fc8
leaq 0xd3c(%rip), %rsi       # 0x3141
movl $0x4, %edx
callq 0x2120
movq 0x8(%rsp), %rsi
movq 0x2bad(%rip), %rbx      # 0x4fc8
movq %rbx, %rdi
callq 0x20a0
leaq 0xd1c(%rip), %rsi       # 0x3146
movl $0x6, %edx
movq %rax, %rdi
movq %rax, %r14
callq 0x2120
movq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x20a0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20b0
movq 0x8(%rsp), %rax
movq %rax, %rcx
shrq $0x3e, %rcx
shlq $0x2, %rax
negq %rcx
sbbq %rdi, %rdi
orq %rax, %rdi
callq 0x2030
leaq 0x20(%rsp), %r15
movq %rax, %r14
movq %r12, (%r15)
leaq 0xcac(%rip), %rsi       # 0x314d
leaq 0xcaf(%rip), %rdx       # 0x3157
movq %r15, %rdi
callq 0x2bc4
leaq 0x50(%rsp), %rax
leaq 0x40(%rsp), %r12
movq %rax, -0x10(%rax)
leaq 0xc93(%rip), %rsi       # 0x3158
leaq 0xc99(%rip), %rdx       # 0x3165
movq %r12, %rdi
callq 0x2bc4
leaq 0x70(%rsp), %rax
leaq 0x60(%rsp), %r12
movq %rax, -0x10(%rax)
leaq 0xc7d(%rip), %rsi       # 0x3166
leaq 0xc80(%rip), %rdx       # 0x3170
movq %r12, %rdi
callq 0x2bc4
leaq 0x90(%rsp), %r13
leaq 0x80(%rsp), %r12
movq %r13, -0x10(%r13)
leaq 0xc5e(%rip), %rsi       # 0x3171
leaq 0xc61(%rip), %rdx       # 0x317b
movq %r12, %rdi
callq 0x2bc4
movq 0x8(%rsp), %rsi
movabsq $0x3fffffffffffffff, %r12 # imm = 0x3FFFFFFFFFFFFFFF
cmpq $0x33, %rsi
jae 0x2638
xorl %r15d, %r15d
vpmovsxbq 0xbc0(%rip), %zmm4 # 0x3108
vpmovsxbq 0xbbe(%rip), %zmm5 # 0x3110
vpbroadcastd 0xba4(%rip), %zmm6 # 0x3100
testq %rsi, %rsi
je 0x25c2
vpmovsxbd 0xbb5(%rip), %zmm1 # 0x3120
leaq (%rsi,%r12), %rax
movq %rax, %rcx
andl $0xf, %eax
andq %r12, %rcx
negq %rax
vpbroadcastq %rcx, %zmm0
leaq 0x10(%rcx,%rax), %rax
xorl %ecx, %ecx
vpbroadcastq %rcx, %zmm2
vporq %zmm4, %zmm2, %zmm3
vporq %zmm5, %zmm2, %zmm2
vpcmpleuq %zmm0, %zmm2, %k0
vpcmpleuq %zmm0, %zmm3, %k1
kunpckbw %k0, %k1, %k1
vmovdqu32 %zmm1, (%r14,%rcx,4) {%k1}
addq $0x10, %rcx
vpaddd %zmm6, %zmm1, %zmm1
cmpq %rcx, %rax
jne 0x2588
movq %r14, %rdi
vzeroupper
callq 0x2aa6
movq 0x8(%rsp), %rax
movq 0x18(%rsp), %rcx
leaq (%r14,%rax,4), %rdx
shlq $0x2, %rcx
movq %rdx, %rsi
subq %rcx, %rsi
movq %r14, %rdi
callq 0x2c59
movq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x2aa6
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20b0
incl %r15d
cmpl $0x4, %r15d
je 0x272d
movq 0x8(%rsp), %rsi
jmp 0x253e
xorl %ebp, %ebp
leaq 0x273f(%rip), %r15      # 0x4d80
vpmovsxbq 0xabd(%rip), %zmm4 # 0x3108
vpmovsxbq 0xabb(%rip), %zmm5 # 0x3110
vpbroadcastd 0xaa1(%rip), %zmm6 # 0x3100
testq %rsi, %rsi
je 0x26c4
vpmovsxbd 0xab2(%rip), %zmm1 # 0x3120
addq %r12, %rsi
movq %rsi, %rcx
andl $0xf, %esi
andq %r12, %rcx
negq %rsi
vpbroadcastq %rcx, %zmm0
leaq 0x10(%rcx,%rsi), %rax
xorl %ecx, %ecx
vpbroadcastq %rcx, %zmm2
vporq %zmm4, %zmm2, %zmm3
vporq %zmm5, %zmm2, %zmm2
vpcmpleuq %zmm0, %zmm2, %k0
vpcmpleuq %zmm0, %zmm3, %k1
kunpckbw %k0, %k1, %k1
vmovdqu32 %zmm1, (%r14,%rcx,4) {%k1}
addq $0x10, %rcx
vpaddd %zmm6, %zmm1, %zmm1
cmpq %rcx, %rax
jne 0x268a
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq $0x14, 0x10(%rbx,%rax)
movq %rbp, %rax
shlq $0x5, %rax
movq 0x28(%rsp,%rax), %rdx
movq 0x20(%rsp,%rax), %rsi
movq %rbx, %rdi
vzeroupper
callq 0x2120
movl $0x3, %edx
leaq 0xa80(%rip), %rsi       # 0x317c
movq %rax, %rdi
callq 0x2120
movq 0x18(%rsp), %rdx
movq 0x8(%rsp), %rsi
movq (%r15,%rbp,8), %rcx
movq %r14, %rdi
callq 0x2b47
incq %rbp
cmpq $0x4, %rbp
je 0x272d
movq 0x8(%rsp), %rsi
jmp 0x2641
movq $-0x80, %rbx
movq -0x10(%r13), %rdi
cmpq %rdi, %r13
je 0x2749
movq (%r13), %rsi
incq %rsi
callq 0x2110
addq $-0x20, %r13
addq $0x20, %rbx
jne 0x2734
movq 0x2866(%rip), %rbx      # 0x4fc0
leaq 0xa8(%rsp), %rdi
movq %rbx, %rsi
callq 0x2140
leaq 0x120(%rsp), %rdi
callq 0x2060
leaq 0x228(%rsp), %rdi
movq %rbx, %rsi
callq 0x2140
leaq 0x2a0(%rsp), %rdi
callq 0x2060
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 0x22dc
jmp 0x27b4
jmp 0x27b4
addq $-0x10, %r12
movq %rax, %rbx
movq -0x10(%r12), %rdi
cmpq %rdi, %r12
je 0x27d1
movq (%r12), %rsi
incq %rsi
callq 0x2110
leaq -0x20(%r12), %rax
addq $-0x10, %r12
cmpq %r15, %r12
movq %rax, %r12
jne 0x27bb
jmp 0x287f
jmp 0x284b
jmp 0x284b
leaq 0x30(%rsp), %rcx
movq %rax, %rbx
movq -0x10(%rcx), %rdi
cmpq %rcx, %rdi
je 0x28a0
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2110
jmp 0x28a0
jmp 0x2814
movq %rax, %rbx
jmp 0x28a0
leaq 0xb8(%rsp), %rcx
movq %rax, %rbx
movq -0x10(%rcx), %rdi
cmpq %rcx, %rdi
je 0x28c1
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2110
jmp 0x28c1
movq %rax, %rbx
jmp 0x28c1
movq %rax, %rbx
jmp 0x287f
jmp 0x2852
movq %rax, %rbx
xorl %r14d, %r14d
movq 0x80(%rsp,%r14), %rdi
leaq (%r13,%r14), %rax
cmpq %rdi, %rax
je 0x2875
movq (%rax), %rsi
incq %rsi
callq 0x2110
addq $-0x20, %r14
cmpq $-0x80, %r14
jne 0x2858
movq 0x273a(%rip), %rsi      # 0x4fc0
leaq 0xa8(%rsp), %rdi
callq 0x2140
leaq 0x120(%rsp), %rdi
callq 0x2060
movq 0x2719(%rip), %rsi      # 0x4fc0
leaq 0x228(%rsp), %rdi
callq 0x2140
leaq 0x2a0(%rsp), %rdi
callq 0x2060
movq %rbx, %rdi
callq 0x2190