// File: /workspace/github_cpp_makefile_star2_O3/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 0x215e
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 0x22d4
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, %rcx
subq 0x48(%rsp), %rcx
shrq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
shlq $0x6, %rcx
movq 0x40(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x58(%rsp), %rdi
movq %rdx, %r8
subq %rdi, %r8
sarq $0x3, %r8
addq %rcx, %r8
subq 0x30(%rsp), %rsi
sarq $0x3, %rsi
addq %r8, %rsi
je 0x1799
cmpq %rdi, %rdx
je 0x166b
leaq -0x8(%rdx), %rax
movl -0x8(%rdx), %ecx
movl %ecx, 0x4(%rsp)
movl -0x4(%rdx), %edi
movl %edi, 0x8(%rsp)
jmp 0x16bb
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
movl 0x4(%rsp), %ecx
movl 0x8(%rsp), %edi
movq %rax, 0x50(%rsp)
cmpl %edi, %ecx
je 0x1607
movslq %ecx, %rsi
leaq (%rsp,%rsi), %rdx
addq $0x10, %rdx
movslq %edi, %r9
leaq (%rsp,%r9), %r8
addq $0x10, %r8
leaq (%rsp,%rsi), %rdi
addq $0x11, %rdi
cmpq %r8, %rdi
je 0x1711
movb 0x10(%rsp,%rsi), %r8b
notq %rsi
addq %r9, %rsi
movzbl (%rdi), %r9d
cmpb %r8b, %r9b
movzbl %r8b, %r8d
cmovbl %r9d, %r8d
cmovbq %rdi, %rdx
incq %rdi
decq %rsi
jne 0x16f6
subq %r15, %rdx
movl %edx, 0xc(%rsp)
movslq %ebp, %rsi
movb %dl, 0x70(%rsp,%rsi)
movq 0x60(%rsp), %rdx
leaq -0x8(%rdx), %rsi
cmpq %rsi, %rax
je 0x1741
movl %ecx, (%rax)
movl 0xc(%rsp), %ecx
movl %ecx, 0x4(%rax)
addq $0x8, %rax
movq %rax, 0x50(%rsp)
jmp 0x1761
movq %rbx, %rdi
leaq 0x4(%rsp), %rsi
leaq 0xc(%rsp), %rdx
callq 0x24f0
movl 0xc(%rsp), %ecx
movq 0x50(%rsp), %rax
movq 0x60(%rsp), %rdx
incl %ecx
movl %ecx, 0x1c(%rsp)
addq $-0x8, %rdx
cmpq %rdx, %rax
je 0x1784
movl %ecx, (%rax)
movl 0x8(%rsp), %ecx
movl %ecx, 0x4(%rax)
addq $0x8, %rax
movq %rax, 0x50(%rsp)
jmp 0x1792
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x25c0
incl %ebp
jmp 0x1607
leaq 0x20(%rsp), %rdi
callq 0x1f16
movq 0x70(%rsp), %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x17bb
jmp 0x17bb
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x1f16
movq %rbx, %rdi
callq 0x1170