// File: /workspace/github_cpp_makefile_star2_O1/wx-csy[P]librmq/prep.cpp
// Function: perm_to_preorder(std::array<unsigned char, 8ul>)
preorder_t perm_to_preorder(perm_t perm) {
    preorder_t result;
    int ptr = 0;
    std::stack<std::pair<int, int>> stk; stk.emplace(0, SEG_LENGTH);
    while (stk.size()) {
        int l, r; std::tie(l, r) = stk.top(); stk.pop();
        if (l == r) continue;
        int m = std::min_element(perm.begin() + l, perm.begin() + r) - perm.begin();
        result[ptr++] = m;
        stk.emplace(l, m);
        stk.emplace(m + 1, r);
    }
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, 0x10(%rsp)
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rbx
movaps %xmm0, 0x40(%rbx)
movaps %xmm0, 0x30(%rbx)
movaps %xmm0, 0x20(%rbx)
movaps %xmm0, 0x10(%rbx)
movaps %xmm0, (%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2116
movl $0x0, 0x4(%rsp)
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x15d5
movabsq $0x800000000, %rcx      # imm = 0x800000000
movq %rcx, (%rax)
addq $0x8, %rax
movq %rax, 0x50(%rsp)
jmp 0x15eb
leaq 0x1a44(%rip), %rdx      # 0x3020
leaq 0x20(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x228c
xorl %ebp, %ebp
movl $0x1f8, %r14d           # imm = 0x1F8
leaq 0x10(%rsp), %r15
leaq 0x20(%rsp), %rbx
leaq 0x1c(%rsp), %r12
leaq 0x8(%rsp), %r13
movq 0x68(%rsp), %rax
movq %rax, %rdx
subq 0x48(%rsp), %rdx
shrq $0x3, %rdx
cmpq $0x1, %rax
adcq $-0x1, %rdx
shlq $0x6, %rdx
movq 0x40(%rsp), %rsi
movq 0x50(%rsp), %rcx
movq 0x58(%rsp), %rdi
movq %rcx, %r8
subq %rdi, %r8
sarq $0x3, %r8
addq %rdx, %r8
subq 0x30(%rsp), %rsi
sarq $0x3, %rsi
addq %r8, %rsi
je 0x1798
cmpq %rdi, %rcx
je 0x166b
leaq -0x8(%rcx), %rax
movl -0x8(%rcx), %edx
movl %edx, 0x4(%rsp)
movl -0x4(%rcx), %ecx
movl %ecx, 0x8(%rsp)
jmp 0x16b3
movq -0x8(%rax), %rax
movl 0x1f8(%rax), %ecx
movl %ecx, 0x4(%rsp)
movl 0x1fc(%rax), %eax
movl %eax, 0x8(%rsp)
movl $0x200, %esi            # imm = 0x200
callq 0x10e0
movq 0x68(%rsp), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x68(%rsp)
movq -0x8(%rax), %rax
movq %rax, 0x58(%rsp)
leaq 0x200(%rax), %rcx
movq %rcx, 0x60(%rsp)
addq %r14, %rax
movq %rax, 0x50(%rsp)
movl 0x4(%rsp), %ecx
movslq 0x8(%rsp), %r8
cmpl %r8d, %ecx
je 0x1607
movslq %ecx, %rdx
leaq (%rsp,%rdx), %rdi
addq $0x10, %rdi
leaq (%rsp,%r8), %r9
addq $0x10, %r9
leaq (%rsp,%rdx), %rsi
addq $0x11, %rsi
cmpq %r9, %rsi
je 0x170b
notq %rdx
addq %r8, %rdx
movb (%rsi), %r9b
movq %rsi, %r8
cmpb (%rdi), %r9b
jb 0x16fe
movq %rdi, %r8
incq %rsi
movq %r8, %rdi
decq %rdx
jne 0x16f0
jmp 0x170e
movq %rdi, %r8
subq %r15, %r8
movl %r8d, 0xc(%rsp)
movslq %ebp, %rdx
movb %r8b, 0x70(%rsp,%rdx)
movq 0x60(%rsp), %rdx
addq $-0x8, %rdx
cmpq %rdx, %rax
je 0x1740
movl %ecx, (%rax)
movl 0xc(%rsp), %ecx
movl %ecx, 0x4(%rax)
addq $0x8, %rax
movq %rax, 0x50(%rsp)
jmp 0x1752
movq %rbx, %rdi
leaq 0x4(%rsp), %rsi
leaq 0xc(%rsp), %rdx
callq 0x24a8
movl 0xc(%rsp), %ecx
incl %ecx
movl %ecx, 0x1c(%rsp)
movq 0x50(%rsp), %rax
movq 0x60(%rsp), %rdx
addq $-0x8, %rdx
cmpq %rdx, %rax
je 0x1783
movl %ecx, (%rax)
movl 0x8(%rsp), %ecx
movl %ecx, 0x4(%rax)
addq $0x8, %rax
movq %rax, 0x50(%rsp)
jmp 0x1791
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x2578
incl %ebp
jmp 0x1607
leaq 0x20(%rsp), %rdi
callq 0x1edc
movq 0x70(%rsp), %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x17ba
jmp 0x17ba
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x1edc
movq %rbx, %rdi
callq 0x1170