// File: /workspace/github_cpp_makefile_star2_O3/EverybodyHops[P]Permutations/./permutations.hpp
// Function: ortho_transposition<int>::ortho_transposition(std::vector<int, std::allocator<int>>)
ortho_transposition(vector<T> init_per){
        this->ordered_element = init_per;
        sort(this->ordered_element.begin(), this->ordered_element.end());

        //permutation to media number
        vector<int> t;
        int temp, direct;

        // 1 is right, 0 is left
        direct = 0;
        start[0] = init_per.size() - 1; end[0] = -1; step[0] = -1;
        start[1] = 0; end[1] = init_per.size(); step[1] = 1;
        
        for(int i = 1; i < this->ordered_element.size(); i++){
            temp = 0;
            for(int j = start[direct]; j != end[direct]; j += step[direct]){
                if(init_per[j] < this->ordered_element[i]){
                    temp += 1;
                }
                if(init_per[j] == this->ordered_element[i]){
                    break;
                }
            }
            t.push_back(temp);
            if(i % 2 == 1){
                direct = t[i - 1] % 2;
            }else{
                direct = (t[i - 1] + t[i - 2]) % 2;
            }
        }
        reverse(t.begin(), t.end());
        this->media_num = new decrease_carry(t);

        #ifdef DEBUG
            this->media_num->print_num();
        #endif
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
movq %rdi, %rbx
addq $0x10, %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movq $0x0, 0x20(%rbx)
leaq 0x4a1f(%rip), %rax      # 0x8d68
movq %rax, (%rbx)
callq 0x4e5a
movq 0x10(%rbx), %r15
movq 0x18(%rbx), %r12
cmpq %r12, %r15
je 0x4395
movq %r12, %rax
subq %r15, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x4f40
movq %r15, %rdi
movq %r12, %rsi
callq 0x5021
movq 0x10(%rbx), %r15
movq 0x18(%rbx), %rax
jmp 0x4398
movq %r15, %rax
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movq 0x8(%r14), %rcx
subq (%r14), %rcx
shrq $0x2, %rcx
leal -0x1(%rcx), %edx
movl %edx, 0x28(%rbx)
movabsq $0x1ffffffff, %rdx      # imm = 0x1FFFFFFFF
movq %rdx, 0x38(%rbx)
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
movq %rdx, 0x2c(%rbx)
movl %ecx, 0x34(%rbx)
subq %r15, %rax
cmpq $0x5, %rax
jb 0x44d3
xorl %ecx, %ecx
movl $0x1, %r12d
leaq -0x2c(%rbp), %r13
movl $0x0, -0x2c(%rbp)
movslq %ecx, %rcx
movl 0x28(%rbx,%rcx,4), %edx
movl 0x30(%rbx,%rcx,4), %esi
movl $0x0, %eax
cmpl %esi, %edx
je 0x443a
movq (%r14), %rdi
movl (%r15,%r12,4), %r8d
xorl %eax, %eax
movslq %edx, %r10
movl (%rdi,%r10,4), %r9d
cmpl %r8d, %r9d
jge 0x442d
incl %eax
movl %eax, -0x2c(%rbp)
movl (%rdi,%r10,4), %r9d
movl (%r15,%r12,4), %r8d
cmpl %r8d, %r9d
je 0x443a
addl 0x38(%rbx,%rcx,4), %edx
cmpl %esi, %edx
jne 0x4414
movq -0x48(%rbp), %rsi
cmpq -0x40(%rbp), %rsi
je 0x4450
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x48(%rbp)
jmp 0x445c
leaq -0x50(%rbp), %rdi
movq %r13, %rdx
callq 0x2d22
movq -0x50(%rbp), %rax
movl -0x4(%rax,%r12,4), %ecx
testb $0x1, %r12b
jne 0x4470
addl -0x8(%rax,%r12,4), %ecx
movl %ecx, %edx
shrl $0x1f, %edx
addl %ecx, %edx
andl $-0x2, %edx
subl %edx, %ecx
incq %r12
movq 0x10(%rbx), %r15
movq 0x18(%rbx), %rdx
subq %r15, %rdx
sarq $0x2, %rdx
cmpq %r12, %rdx
ja 0x43f0
movq -0x48(%rbp), %rcx
cmpq %rcx, %rax
setne %dl
addq $-0x4, %rcx
cmpq %rax, %rcx
seta %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x44d3
addq $0x4, %rax
movl -0x4(%rax), %edx
movl (%rcx), %esi
movl %esi, -0x4(%rax)
movl %edx, (%rcx)
addq $-0x4, %rcx
leaq 0x4(%rax), %rdx
cmpq %rcx, %rax
movq %rdx, %rax
jb 0x44b9
movl $0x30, %edi
callq 0x20e0
movq %rax, %r15
leaq -0x68(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2c56
leaq -0x68(%rbp), %rsi
movq %r15, %rdi
callq 0x2b6e
movq %r15, 0x8(%rbx)
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x450b
callq 0x20c0
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x4519
callq 0x20c0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x453e
callq 0x20c0
jmp 0x453e
movq %rax, %r14
movq %r15, %rdi
callq 0x20c0
jmp 0x4552
jmp 0x454f
movq %rax, %r14
jmp 0x4560
movq %rax, %r14
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x4560
callq 0x20c0
movq %rbx, %rdi
callq 0x4d84
movq %r14, %rdi
callq 0x2140