// Wave-6 slice 6-assembler: SSE group (ucomisd, comisd, pshufd, movdqa/movdqu,
// pcmpeqb, pmovmskb, punpcklbw) — encoder expansion group
// Expected exit code: 42
section .data
align 16
vec_a: dd 1, 2, 3, 4
vec_b: dd 1, 2, 3, 4
one_point_five: dq 0x3FF8000000000000
two_point_zero: dq 0x4000000000000000

section .text
global main
main:
    ; ucomisd: 1.5 vs 2.0 -> below
    movsd xmm0, qword [rel one_point_five]
    ucomisd xmm0, qword [rel two_point_zero]
    setb cl               ; cl = 1
    ; comisd: 2.0 vs 1.5 -> above
    movsd xmm0, qword [rel two_point_zero]
    comisd xmm0, qword [rel one_point_five]
    seta ch               ; ch = 1
    ; pshufd identity shuffle (0b11100100 = 0xE4) keeps lanes
    movdqa xmm1, [rel vec_a]
    pshufd xmm2, xmm1, 0xE4
    pcmpeqd xmm2, xmm1    ; all lanes equal -> all ones
    pmovmskb eax, xmm2    ; eax = 0xFFFF
    cmp eax, 0xFFFF
    jne fail
    ; unaligned load/store roundtrip
    movdqu xmm3, [rel vec_b]
    movdqu [rel vec_a], xmm3
    mov eax, dword [rel vec_a+12]
    cmp eax, 4
    jne fail
    movzx eax, cl         ; 1
    movzx ecx, ch         ; 1
    add eax, ecx          ; 2
    add eax, 40           ; 42
    ret
fail:
    mov eax, 1
    ret
