// File: /workspace/github_cpp_makefile_star2_O3/EverybodyHops[P]Permutations/magic_square.cpp
// Function: magic_square::get_magic_square(int)
vector<vector<int>> get_magic_square(int rank){
        int rank_2;
        rank_2 = rank * rank;

        // initialize
        vector<int> p;
        for(int i = 0; i < rank_2; i++){
            p.push_back(i + 1);
        }
        int k = 0;
        int magic_sum = rank * (rank_2 + 1) / 2;

        // start algorithm
        vector<vector<int>> ans;
        dic_order<int> *dop;
        bool flag = true;
        while(flag){
            if(add(p, k, rank) == magic_sum){
                k += rank;
                if(k == rank_2){
                    k = 0;
                    if(if_magic_square(p, rank, magic_sum)){
                        ans.push_back(p);
                    }
                    dop = new dic_order<int>(p);
                    flag = dop->next_one();
                    p = dop->get_permutation();
                    delete dop;
                }
            }else{
                sort(p.begin() + k + rank, p.end(), greater<int>());
                dop = new dic_order<int>(p);
                flag = dop->next_one();
                p = dop->get_permutation();
                delete dop;
            }
        }
        return ans;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rsi, -0x80(%rbp)
movq %rdi, -0x50(%rbp)
movl %edx, %eax
imull %eax, %eax
movq %rax, -0x78(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movq $0x0, -0x30(%rbp)
movq %rdx, -0x58(%rbp)
testl %edx, %edx
je 0x21c0
xorl %r14d, %r14d
movq -0x78(%rbp), %rax
cmpl $0x1, %eax
sbbl %eax, %r14d
movl $0x1, %r12d
leaq -0x40(%rbp), %rbx
leaq -0x70(%rbp), %r15
movl %r12d, -0x70(%rbp)
movq -0x38(%rbp), %rsi
cmpq -0x30(%rbp), %rsi
je 0x21a2
movl %r12d, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x38(%rbp)
jmp 0x21ad
movq %rbx, %rdi
movq %r15, %rdx
callq 0x1eac
leal (%r14,%r12), %eax
incl %eax
movl %r12d, %ecx
incl %ecx
movl %ecx, %r12d
cmpl $0x1, %eax
jne 0x2187
movq -0x78(%rbp), %rax
leal 0x1(%rax), %edx
movq -0x58(%rbp), %rcx
imull %ecx, %edx
movl %edx, %eax
shrl $0x1f, %eax
addl %edx, %eax
sarl %eax
movl %eax, -0x48(%rbp)
movq -0x50(%rbp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movl %ecx, %ebx
movslq %ecx, %rax
movq %rax, -0x88(%rbp)
incl %edx
movl %edx, -0x44(%rbp)
xorl %eax, %eax
movslq %eax, %r15
leaq (,%r15,4), %r14
leaq -0xe8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1cc6
movq -0xe8(%rbp), %rdi
cmpl $0x0, -0x58(%rbp)
jle 0x224c
leaq (%rdi,%r15,4), %rax
xorl %ecx, %ecx
xorl %r12d, %r12d
addl (%rax,%rcx,4), %r12d
incq %rcx
cmpq %rcx, %rbx
jne 0x2230
callq 0x10f0
cmpl -0x48(%rbp), %r12d
jne 0x226b
jmp 0x2361
testq %rdi, %rdi
je 0x2261
callq 0x10f0
cmpl $0x3, -0x44(%rbp)
jae 0x226b
jmp 0x2361
cmpl $0x2, -0x44(%rbp)
jbe 0x2361
movq -0x40(%rbp), %rax
addq %r14, %rax
movq -0x88(%rbp), %rcx
leaq (%rax,%rcx,4), %r12
movq -0x38(%rbp), %r13
cmpq %r13, %r12
je 0x22b3
movq %r13, %rax
subq %r12, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x33cd
movq %r12, %rdi
movq %r13, %rsi
callq 0x34ae
movl $0x28, %edi
callq 0x1110
movq %rax, %r13
leaq -0xb8(%rbp), %r12
movq %r12, %rdi
leaq -0x40(%rbp), %rsi
callq 0x1cc6
movq %r13, %rdi
movq %r12, %rsi
callq 0x2926
movq -0xb8(%rbp), %rdi
testq %rdi, %rdi
je 0x22ef
callq 0x10f0
movq 0x8(%r13), %rdi
callq 0x18f2
movl %eax, %r12d
movq (%r13), %rax
leaq -0x70(%rbp), %rdi
movq %r13, %rsi
callq *(%rax)
movq -0x40(%rbp), %rdi
movq -0x70(%rbp), %rax
movq %rax, -0x40(%rbp)
movups -0x68(%rbp), %xmm0
movups %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
movq $0x0, -0x60(%rbp)
testq %rdi, %rdi
je 0x2343
callq 0x10f0
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x2343
callq 0x10f0
movq %r13, %rdi
callq 0x2b3c
movq %r13, %rdi
callq 0x10f0
testb %r12b, %r12b
jne 0x220a
jmp 0x246b
movq -0x58(%rbp), %rax
addl %r15d, %eax
cmpl -0x78(%rbp), %eax
jne 0x21ff
leaq -0xa0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1cc6
movq -0x80(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
movq -0x58(%rbp), %rdx
movl -0x48(%rbp), %ecx
callq 0x2772
movl %eax, %r12d
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x23ac
callq 0x10f0
testb %r12b, %r12b
je 0x23be
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x28ea
movl $0x28, %edi
callq 0x1110
movq %rax, %r15
leaq -0xd0(%rbp), %r14
movq %r14, %rdi
leaq -0x40(%rbp), %rsi
callq 0x1cc6
movq %r15, %rdi
movq %r14, %rsi
callq 0x2926
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0x23fa
callq 0x10f0
movq 0x8(%r15), %rdi
callq 0x18f2
movl %eax, %r13d
movq (%r15), %rax
leaq -0x70(%rbp), %rdi
movq %r15, %rsi
callq *(%rax)
movq -0x40(%rbp), %rdi
movq -0x70(%rbp), %rax
movq %rax, -0x40(%rbp)
movups -0x68(%rbp), %xmm0
movups %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
movq $0x0, -0x60(%rbp)
testq %rdi, %rdi
je 0x244d
callq 0x10f0
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x244d
callq 0x10f0
movq %r15, %rdi
callq 0x2b3c
movq %r15, %rdi
callq 0x10f0
movl $0x0, %eax
testb %r13b, %r13b
jne 0x21ff
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x2479
callq 0x10f0
movq -0x50(%rbp), %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x24ee
movq %rax, %rbx
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0x24aa
callq 0x10f0
jmp 0x24aa
movq %rax, %rbx
movq %r15, %rdi
jmp 0x24e3
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
jne 0x24e3
jmp 0x24f1
jmp 0x24ee
movq %rax, %rbx
jmp 0x24fa
movq %rax, %rbx
jmp 0x24e0
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
testq %rdi, %rdi
je 0x24e0
callq 0x10f0
movq %r13, %rdi
callq 0x10f0
jmp 0x24f1
jmp 0x24ee
jmp 0x24ee
movq %rax, %rbx
movq -0x50(%rbp), %rdi
callq 0x271e
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x2508
callq 0x10f0
movq %rbx, %rdi
callq 0x1190