// File: /workspace/github_cpp_makefile_star2_O1/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 0x4a9b(%rip), %rax      # 0x8d68
movq %rax, (%rbx)
callq 0x4dd6
movq 0x10(%rbx), %r15
movq 0x18(%rbx), %r12
cmpq %r12, %r15
je 0x430f
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 0x4eae
movq %r15, %rdi
movq %r12, %rsi
callq 0x4f8f
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
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)
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rcx
subq %rax, %rcx
cmpq $0x5, %rcx
jb 0x4412
xorl %ecx, %ecx
movl $0x1, %r13d
leaq -0x50(%rbp), %r15
leaq -0x2c(%rbp), %r12
movl $0x0, -0x2c(%rbp)
movslq %ecx, %rcx
movl 0x28(%rbx,%rcx,4), %edx
movl 0x30(%rbx,%rcx,4), %esi
cmpl %esi, %edx
je 0x43b3
movl -0x2c(%rbp), %edi
movq (%r14), %r8
movslq %edx, %r9
movl (%r8,%r9,4), %r10d
cmpl (%rax,%r13,4), %r10d
jge 0x43a1
incl %edi
movl %edi, -0x2c(%rbp)
movl (%r8,%r9,4), %r9d
cmpl (%rax,%r13,4), %r9d
je 0x43b3
addl 0x38(%rbx,%rcx,4), %edx
cmpl %esi, %edx
jne 0x438f
movq -0x48(%rbp), %rsi
cmpq -0x40(%rbp), %rsi
je 0x43cc
movl -0x2c(%rbp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x48(%rbp)
jmp 0x43d7
movq %r15, %rdi
movq %r12, %rdx
callq 0x2cf8
movq -0x50(%rbp), %rax
movl -0x4(%rax,%r13,4), %ecx
testb $0x1, %r13b
jne 0x43eb
addl -0x8(%rax,%r13,4), %ecx
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
andl $-0x2, %eax
subl %eax, %ecx
incq %r13
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
ja 0x4373
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
cmpq %rcx, %rax
setne %dl
addq $-0x4, %rcx
cmpq %rax, %rcx
seta %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x4452
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 0x4438
movl $0x30, %edi
callq 0x20e0
movq %rax, %r15
leaq -0x68(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2c2c
leaq -0x68(%rbp), %rsi
movq %r15, %rdi
callq 0x2b4e
movq %r15, 0x8(%rbx)
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x448a
callq 0x20c0
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x4498
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 0x44bd
callq 0x20c0
jmp 0x44bd
movq %rax, %r14
movq %r15, %rdi
callq 0x20c0
jmp 0x44d1
jmp 0x44ce
movq %rax, %r14
jmp 0x44df
movq %rax, %r14
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x44df
callq 0x20c0
movq %rbx, %rdi
callq 0x4cf2
movq %r14, %rdi
callq 0x2140
nop