Byte-exact, all four functions, whole object. Source was a pure skeleton with
no code; status MISSING work now NonMatching -> Matching.
An iterative quicksort for 2-byte and 4-byte elements with a 30-deep bounds
stack and a selection-sort cutoff at 8. The two code_* symbols are the
selection sorts and take hi in EAX under VC7's custom convention for statics.
The comparator takes values, not pointers, and the zero-extension in the target
pins the 2-byte element type to word rather than short.
Five source-shape findings, each read off the disassembly:
- the swap loads both elements then stores to *best first, which is
temp = *best; *best = *hi; *hi = temp - the mirror of the natural form. That
alone made both selection sorts exact.
- element_count and size are unsigned: the target uses jb, ja and shr where
signed types give jl, jg and sar.
- the source writes lo+1 < j, not the algebraically identical lo < j-1, which
reverses the lea and cmp operands.
- the larger-partition test compares raw byte differences. On word pointers
every element-count form makes MSVC emit two sars or cancel them and mask,
costing 16 bytes; only an explicit byte-basis comparison gives the plain dec.
j-1-lo >= hi-i, j-lo > hi-i and the byte form are integer-identical and only
the last matches.
- depth = 0 is assigned before hi; the reverse order swaps the two stores.
Both qsort bodies went exact from the same five fixes, which is good evidence
the shapes are right rather than coincidental.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>