// File: /workspace/github_cpp_makefile_star2_O1/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, -0x58(%rbp)
movl %edx, %eax
imull %eax, %eax
movq %rax, -0x78(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movl %edx, -0x2c(%rbp)
testl %edx, %edx
je 0x2183
xorl %r12d, %r12d
movq -0x78(%rbp), %rax
cmpl $0x1, %eax
sbbl %eax, %r12d
movl $0x1, %r13d
leaq -0x50(%rbp), %rbx
leaq -0x70(%rbp), %r15
movl %r13d, -0x70(%rbp)
movq -0x48(%rbp), %rsi
cmpq -0x40(%rbp), %rsi
je 0x2165
movl %r13d, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x48(%rbp)
jmp 0x2170
movq %rbx, %rdi
movq %r15, %rdx
callq 0x1e82
leal (%r12,%r13), %eax
incl %eax
movl %r13d, %ecx
incl %ecx
movl %ecx, %r13d
cmpl $0x1, %eax
jne 0x214a
movq -0x78(%rbp), %rax
incl %eax
movl -0x2c(%rbp), %ecx
imull %ecx, %eax
movl %eax, %edx
shrl $0x1f, %edx
addl %eax, %edx
sarl %edx
movl %edx, -0x34(%rbp)
movq -0x58(%rbp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movl %ecx, %ebx
movslq %ecx, %rax
movq %rax, -0x88(%rbp)
movl $0x0, -0x30(%rbp)
movb $0x1, %r15b
leaq -0x50(%rbp), %r14
leaq -0xe8(%rbp), %rdi
movq %r14, %rsi
callq 0x1c9c
movq %r14, %r12
movslq -0x30(%rbp), %r13
cmpl $0x0, -0x2c(%rbp)
jle 0x2205
leaq (,%r13,4), %rax
addq -0xe8(%rbp), %rax
xorl %ecx, %ecx
xorl %r14d, %r14d
addl (%rax,%rcx,4), %r14d
incq %rcx
cmpq %rcx, %rbx
jne 0x21f7
jmp 0x2208
xorl %r14d, %r14d
movq -0xe8(%rbp), %rdi
testq %rdi, %rdi
je 0x2219
callq 0x10f0
cmpl -0x34(%rbp), %r14d
jne 0x231d
movl -0x30(%rbp), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x30(%rbp)
cmpl -0x78(%rbp), %eax
movq %r12, %r14
leaq -0xd0(%rbp), %r12
jne 0x240f
leaq -0xa0(%rbp), %rdi
movq %r14, %rsi
callq 0x1c9c
movq -0x80(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
movl -0x2c(%rbp), %edx
movl -0x34(%rbp), %ecx
callq 0x2704
movl %eax, %r15d
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x2278
callq 0x10f0
testb %r15b, %r15b
je 0x2289
movq -0x58(%rbp), %rdi
movq %r14, %rsi
callq 0x2852
movl $0x28, %edi
callq 0x1110
movq %rax, %r13
movq %r12, %rdi
movq %r14, %rsi
callq 0x1c9c
movq %r13, %rdi
movq %r12, %rsi
callq 0x288e
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0x22bd
callq 0x10f0
movq 0x8(%r13), %rdi
callq 0x18f0
movl %eax, %r15d
movq (%r13), %rax
leaq -0x70(%rbp), %rdi
movq %r13, %rsi
callq *(%rax)
movq -0x50(%rbp), %rdi
movq -0x70(%rbp), %rax
movq %rax, -0x50(%rbp)
movups -0x68(%rbp), %xmm0
movups %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
movq $0x0, -0x60(%rbp)
testq %rdi, %rdi
je 0x2303
callq 0x10f0
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x2311
callq 0x10f0
movl $0x0, -0x30(%rbp)
jmp 0x23ff
shlq $0x2, %r13
addq -0x50(%rbp), %r13
movq -0x88(%rbp), %rax
leaq (,%rax,4), %r15
addq %r13, %r15
movq -0x48(%rbp), %r13
cmpq %r13, %r15
movq %r12, %r14
je 0x2370
movq %r13, %rax
subq %r15, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r15, %rdi
movq %r13, %rsi
callq 0x3341
movq %r15, %rdi
movq %r13, %rsi
callq 0x3422
movl $0x28, %edi
callq 0x1110
movq %rax, %r13
leaq -0xb8(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x1c9c
movq %r13, %rdi
movq %r15, %rsi
callq 0x288e
movq -0xb8(%rbp), %rdi
testq %rdi, %rdi
je 0x23ab
callq 0x10f0
movq 0x8(%r13), %rdi
callq 0x18f0
movl %eax, %r15d
movq (%r13), %rax
leaq -0x70(%rbp), %rdi
movq %r13, %rsi
callq *(%rax)
movq -0x50(%rbp), %rdi
movq -0x70(%rbp), %rax
movq %rax, -0x50(%rbp)
movups -0x68(%rbp), %xmm0
movups %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
movq $0x0, -0x60(%rbp)
testq %rdi, %rdi
je 0x23f1
callq 0x10f0
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x23ff
callq 0x10f0
movq %r13, %rdi
callq 0x2a8c
movq %r13, %rdi
callq 0x10f0
testb $0x1, %r15b
jne 0x21c7
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x2427
callq 0x10f0
movq -0x58(%rbp), %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x2496
movq %rax, %rbx
movq -0xd0(%rbp), %rdi
jmp 0x246d
jmp 0x2479
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
jne 0x247f
jmp 0x248d
jmp 0x248a
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
testq %rdi, %rdi
je 0x247c
callq 0x10f0
jmp 0x247c
movq %rax, %rbx
movq %r13, %rdi
callq 0x10f0
jmp 0x248d
jmp 0x248a
jmp 0x248a
movq %rax, %rbx
movq -0x58(%rbp), %rdi
callq 0x26ba
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x24a4
callq 0x10f0
movq %rbx, %rdi
callq 0x1190