// File: 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
subq $0xd0, %rsp
movq %rsi, -0x90(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x7cf0
movq -0x98(%rbp), %rdi
movq -0x90(%rbp), %rsi
leaq 0xc6b1(%rip), %rax      # 0x12d60
movq %rax, (%rdi)
addq $0x10, %rdi
callq 0x7d20
jmp 0x66bd
movq -0x98(%rbp), %rdi
addq $0x10, %rdi
movq %rdi, -0xa0(%rbp)
callq 0x3290
movq -0xa0(%rbp), %rdi
movq %rax, -0x28(%rbp)
callq 0x32c0
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x7f70
jmp 0x66f7
leaq -0x48(%rbp), %rdi
callq 0x3130
movq -0x90(%rbp), %rdi
movl $0x0, -0x50(%rbp)
callq 0x30f0
movq -0x90(%rbp), %rdi
movq %rax, %rcx
movq -0x98(%rbp), %rax
subq $0x1, %rcx
movl %ecx, 0x28(%rax)
movl $0xffffffff, 0x30(%rax) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x38(%rax) # imm = 0xFFFFFFFF
movl $0x0, 0x2c(%rax)
callq 0x30f0
movq %rax, %rcx
movq -0x98(%rbp), %rax
movl %ecx, 0x34(%rax)
movl $0x1, 0x3c(%rax)
movl $0x1, -0x54(%rbp)
movq -0x98(%rbp), %rdi
movslq -0x54(%rbp), %rax
movq %rax, -0xa8(%rbp)
addq $0x10, %rdi
callq 0x30f0
movq %rax, %rcx
movq -0xa8(%rbp), %rax
cmpq %rcx, %rax
jae 0x690e
movq -0x98(%rbp), %rax
movl $0x0, -0x4c(%rbp)
movslq -0x50(%rbp), %rcx
movl 0x28(%rax,%rcx,4), %eax
movl %eax, -0x58(%rbp)
movq -0x98(%rbp), %rcx
movl -0x58(%rbp), %eax
movslq -0x50(%rbp), %rdx
cmpl 0x30(%rcx,%rdx,4), %eax
je 0x686b
movq -0x90(%rbp), %rdi
movslq -0x58(%rbp), %rsi
callq 0x3110
movq -0x98(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xac(%rbp)
addq $0x10, %rdi
movslq -0x54(%rbp), %rsi
callq 0x3110
movq %rax, %rcx
movl -0xac(%rbp), %eax
cmpl (%rcx), %eax
jge 0x6814
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x6814
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x69f5
movq -0x90(%rbp), %rdi
movslq -0x58(%rbp), %rsi
callq 0x3110
movq -0x98(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xb0(%rbp)
addq $0x10, %rdi
movslq -0x54(%rbp), %rsi
callq 0x3110
movq %rax, %rcx
movl -0xb0(%rbp), %eax
cmpl (%rcx), %eax
jne 0x684f
jmp 0x686b
jmp 0x6851
movq -0x98(%rbp), %rax
movslq -0x50(%rbp), %rcx
movl 0x38(%rax,%rcx,4), %eax
addl -0x58(%rbp), %eax
movl %eax, -0x58(%rbp)
jmp 0x67a7
leaq -0x48(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
callq 0x3150
jmp 0x687a
movl -0x54(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x1, %edx
jne 0x68bc
movl -0x54(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x3110
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %edx, -0x50(%rbp)
jmp 0x68fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x69ec
movl -0x54(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x3110
movl (%rax), %eax
movl %eax, -0xb4(%rbp)
movl -0x54(%rbp), %eax
subl $0x2, %eax
movslq %eax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x3110
movq %rax, %rcx
movl -0xb4(%rbp), %eax
addl (%rcx), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %edx, -0x50(%rbp)
jmp 0x6900
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x6760
leaq -0x48(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x3290
movq -0xc0(%rbp), %rdi
movq %rax, -0x60(%rbp)
callq 0x32c0
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x7fb0
jmp 0x6941
movl $0x30, %edi
callq 0x20f0
movq %rax, -0xc8(%rbp)
jmp 0x6954
movb $0x1, -0x81(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2f70
jmp 0x696a
movq -0xc8(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x2e80
jmp 0x697c
movq -0x98(%rbp), %rax
movq -0xc8(%rbp), %rcx
movb $0x0, -0x81(%rbp)
movq %rcx, 0x8(%rax)
leaq -0x80(%rbp), %rdi
callq 0x3090
leaq -0x48(%rbp), %rdi
callq 0x3090
addq $0xd0, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x69d3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x3090
testb $0x1, -0x81(%rbp)
jne 0x69de
jmp 0x69ea
movq -0xc8(%rbp), %rdi
callq 0x20d0
jmp 0x69ec
leaq -0x48(%rbp), %rdi
callq 0x3090
movq -0x98(%rbp), %rdi
callq 0x7970
movq -0x18(%rbp), %rdi
callq 0x21b0
nopw (%rax,%rax)