// Wave-6 slice 6-assembler: system/misc group — encoder expansion group.
// Potentially CPU-specific encodings (movbe, crc32, cmpxchg16b, xgetbv,
// rdtscp, xsave family, syscall) are placed in a never-called function:
// this verifies encode + COFF emission + link without executing them.
// Expected exit code: 42
section .data
align 16
cmpx_val: dq 0, 0

section .text
global main

never_called:
    movbe rax, [rel cmpx_val]
    movbe [rel cmpx_val], rax
    crc32 eax, byte [rel cmpx_val]
    crc32 eax, dword [rel cmpx_val]
    crc32 rax, qword [rel cmpx_val]
    mov rax, 1
    mov rdx, 2
    cmpxchg16b [rel cmpx_val]
    xor ecx, ecx
    xgetbv
    rdtscp
    xsave [rel cmpx_val]
    xrstor [rel cmpx_val]
    xsaveopt [rel cmpx_val]
    stmxcsr [rel cmpx_val]
    ldmxcsr [rel cmpx_val]
    fxsave [rel cmpx_val]
    fxrstor [rel cmpx_val]
    prefetchnta [rel cmpx_val]
    prefetcht0 [rel cmpx_val]
    clflush [rel cmpx_val]
    syscall
    sysret
    rdrand eax
    rdseed eax
    xlatb
    ret

main:
    ; executed, universally-available system encodings
    lfence
    sfence
    mfence
    mov eax, 1
    cpuid                ; clobbers ebx/ecx/edx
    rdtsc                ; clobbers edx
    mov eax, 42
    ret
