// File: /workspace/github_cpp_makefile_star2_O2/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
andq $0x0, 0x20(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
leaq 0x50f6(%rip), %rax      # 0x7d68
movq %rax, (%rbx)
callq 0x3444
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rsi
callq 0x353e
xorps %xmm0, %xmm0
leaq -0x50(%rbp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movq 0x8(%r14), %rax
subq (%r14), %rax
shrq $0x2, %rax
leal -0x1(%rax), %ecx
movl %ecx, 0x28(%rbx)
movabsq $0x1ffffffff, %rcx      # imm = 0x1FFFFFFFF
movq %rcx, 0x38(%rbx)
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
movq %rcx, 0x2c(%rbx)
movl %eax, 0x34(%rbx)
xorl %edi, %edi
pushq $0x1
popq %r13
leaq -0x2c(%rbp), %r12
pushq $0x2
popq %r15
xorl %edx, %edx
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r13, %rcx
jbe 0x2d53
andl $0x0, -0x2c(%rbp)
movslq %edx, %rcx
movl 0x28(%rbx,%rcx,4), %edx
movl 0x30(%rbx,%rcx,4), %esi
xorl %edi, %edi
cmpl %esi, %edx
je 0x2d2a
movslq %edx, %r10
movq (%r14), %r11
movl (%r11,%r10,4), %r8d
movl (%rax,%r13,4), %r9d
cmpl %r9d, %r8d
jge 0x2d1f
incl %edi
movl %edi, -0x2c(%rbp)
movl (%r11,%r10,4), %r8d
movl (%rax,%r13,4), %r9d
cmpl %r9d, %r8d
je 0x2d2a
addl 0x38(%rbx,%rcx,4), %edx
jmp 0x2cfb
leaq -0x50(%rbp), %rdi
movq %r12, %rsi
callq 0x1a28
movq -0x50(%rbp), %rdi
movl -0x4(%rdi,%r13,4), %eax
testb $0x1, %r13b
jne 0x2d4a
addl -0x8(%rdi,%r13,4), %eax
cltd
idivl %r15d
incq %r13
jmp 0x2cd6
movq -0x48(%rbp), %rsi
callq 0x398e
pushq $0x30
popq %rdi
callq 0x10c0
movq %rax, %r15
leaq -0x68(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x19d0
leaq -0x68(%rbp), %rsi
movq %r15, %rdi
callq 0x1934
movq %r15, 0x8(%rbx)
leaq -0x68(%rbp), %rdi
callq 0x1a6e
leaq -0x50(%rbp), %rdi
callq 0x1a6e
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq -0x68(%rbp), %rdi
callq 0x1a6e
jmp 0x2db6
movq %rax, %r14
movq %r15, %rdi
callq 0x10a0
jmp 0x2dca
jmp 0x2dc7
movq %rax, %r14
jmp 0x2dd3
movq %rax, %r14
leaq -0x50(%rbp), %rdi
callq 0x1a6e
movq %rbx, %rdi
callq 0x33aa
movq %r14, %rdi
callq 0x1120
nop