// File: /workspace/github_cpp_makefile_star2_O2/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 $0xb8, %rsp
movl %edx, %r14d
movq %rsi, -0x60(%rbp)
movq %rdi, -0x38(%rbp)
movl %edx, %r12d
imull %r12d, %r12d
xorps %xmm0, %xmm0
leaq -0x50(%rbp), %rbx
movaps %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
movq %r12, -0x58(%rbp)
negl %r12d
pushq $0x1
popq %r13
leaq -0x80(%rbp), %r15
leal (%r12,%r13), %eax
cmpl $0x1, %eax
je 0x1f53
movl %r13d, -0x80(%rbp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1c3a
incl %r13d
jmp 0x1f36
movq -0x58(%rbp), %rax
incl %eax
imull %r14d, %eax
pushq $0x2
popq %rcx
cltd
idivl %ecx
movl %eax, -0x30(%rbp)
xorps %xmm0, %xmm0
movq -0x38(%rbp), %rax
andq $0x0, 0x10(%rax)
movups %xmm0, (%rax)
movslq %r14d, %rax
movq %rax, -0x68(%rbp)
movb $0x1, %bl
xorl %r12d, %r12d
leaq -0xe0(%rbp), %r13
testb $0x1, %bl
je 0x211c
movq %r13, %rdi
leaq -0x50(%rbp), %rsi
callq 0x1a10
movq -0x60(%rbp), %rdi
movq %r13, %rsi
movl %r12d, %edx
movl %r14d, %ecx
callq 0x231e
movl %eax, %ebx
movq %r13, %rdi
callq 0x1aae
cmpl -0x30(%rbp), %ebx
jne 0x2077
addl %r14d, %r12d
movb $0x1, %bl
cmpl -0x58(%rbp), %r12d
jne 0x1f88
leaq -0x98(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x1a10
movq -0x60(%rbp), %rdi
leaq -0x98(%rbp), %r15
movq %r15, %rsi
movl %r14d, %edx
movl -0x30(%rbp), %ecx
callq 0x2340
movl %eax, %ebx
movq %r15, %rdi
callq 0x1aae
testb %bl, %bl
je 0x2011
movq -0x38(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2486
pushq $0x28
popq %rdi
callq 0x10f0
movq %rax, %r15
leaq -0xc8(%rbp), %rbx
movq %rbx, %rdi
leaq -0x50(%rbp), %rsi
callq 0x1a10
movq %r15, %rdi
movq %rbx, %rsi
callq 0x24c2
movq %rbx, %rdi
callq 0x1aae
movq %r15, %rdi
callq 0x2606
movl %eax, %ebx
movq (%r15), %rax
leaq -0x80(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq *(%rax)
leaq -0x50(%rbp), %rdi
movq %r12, %rsi
callq 0x2fc8
movq %r12, %rdi
callq 0x1aae
xorl %r12d, %r12d
jmp 0x2107
movslq %r12d, %rax
shlq $0x2, %rax
addq -0x50(%rbp), %rax
movq -0x68(%rbp), %rcx
leaq (%rax,%rcx,4), %rdi
movq -0x48(%rbp), %rsi
callq 0x3034
pushq $0x28
popq %rdi
callq 0x10f0
movq %rax, %r15
leaq -0xb0(%rbp), %rbx
movq %rbx, %rdi
leaq -0x50(%rbp), %rsi
callq 0x1a10
movq %r15, %rdi
movq %rbx, %rsi
callq 0x24c2
movq %rbx, %rdi
callq 0x1aae
movq %r15, %rdi
callq 0x2606
movq %r15, %rsi
movb %al, -0x29(%rbp)
movl %r12d, %ebx
movl %r14d, %r12d
movq %r13, %r14
movq (%r15), %rax
leaq -0x80(%rbp), %r13
movq %r13, %rdi
callq *(%rax)
leaq -0x50(%rbp), %rdi
movq %r13, %rsi
callq 0x2fc8
movq %r13, %rdi
callq 0x1aae
movq %r14, %r13
movl %r12d, %r14d
movl %ebx, %r12d
movb -0x29(%rbp), %bl
movq %r15, %rdi
callq 0x2614
movq %r15, %rdi
callq 0x10d0
jmp 0x1f88
leaq -0x50(%rbp), %rdi
callq 0x1aae
movq -0x38(%rbp), %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x1aae
jmp 0x2186
jmp 0x2183
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
jmp 0x2166
jmp 0x216d
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x1aae
jmp 0x2170
movq %rax, %rbx
movq %r15, %rdi
callq 0x10d0
jmp 0x2186
jmp 0x2183
jmp 0x2183
movq %rax, %rbx
jmp 0x218f
movq %rax, %rbx
movq -0x38(%rbp), %rdi
callq 0x22f2
leaq -0x50(%rbp), %rdi
callq 0x1aae
movq %rbx, %rdi
callq 0x1160