Skip to main content

libzstd_rs_sys/lib/compress/
zstd_lazy.rs

1use core::arch::asm;
2pub type ZSTD_longLengthType_e = core::ffi::c_uint;
3pub const ZSTD_llt_matchLength: ZSTD_longLengthType_e = 2;
4pub const ZSTD_llt_literalLength: ZSTD_longLengthType_e = 1;
5pub const ZSTD_llt_none: ZSTD_longLengthType_e = 0;
6#[repr(C)]
7pub struct optState_t {
8    pub litFreq: *mut core::ffi::c_uint,
9    pub litLengthFreq: *mut core::ffi::c_uint,
10    pub matchLengthFreq: *mut core::ffi::c_uint,
11    pub offCodeFreq: *mut core::ffi::c_uint,
12    pub matchTable: *mut ZSTD_match_t,
13    pub priceTable: *mut ZSTD_optimal_t,
14    pub litSum: u32,
15    pub litLengthSum: u32,
16    pub matchLengthSum: u32,
17    pub offCodeSum: u32,
18    pub litSumBasePrice: u32,
19    pub litLengthSumBasePrice: u32,
20    pub matchLengthSumBasePrice: u32,
21    pub offCodeSumBasePrice: u32,
22    pub priceType: ZSTD_OptPrice_e,
23    pub symbolCosts: *const ZSTD_entropyCTables_t,
24    pub literalCompressionMode: ZSTD_ParamSwitch_e,
25}
26pub type ZSTD_ParamSwitch_e = core::ffi::c_uint;
27pub const ZSTD_ps_disable: ZSTD_ParamSwitch_e = 2;
28pub const ZSTD_ps_enable: ZSTD_ParamSwitch_e = 1;
29pub const ZSTD_ps_auto: ZSTD_ParamSwitch_e = 0;
30#[repr(C)]
31pub struct ZSTD_entropyCTables_t {
32    pub huf: ZSTD_hufCTables_t,
33    pub fse: ZSTD_fseCTables_t,
34}
35#[repr(C)]
36pub struct ZSTD_fseCTables_t {
37    pub offcodeCTable: [FSE_CTable; 193],
38    pub matchlengthCTable: [FSE_CTable; 363],
39    pub litlengthCTable: [FSE_CTable; 329],
40    pub offcode_repeatMode: FSE_repeat,
41    pub matchlength_repeatMode: FSE_repeat,
42    pub litlength_repeatMode: FSE_repeat,
43}
44#[repr(C)]
45pub struct ZSTD_hufCTables_t {
46    pub CTable: [HUF_CElt; 257],
47    pub repeatMode: HUF_repeat,
48}
49pub type ZSTD_OptPrice_e = core::ffi::c_uint;
50pub const zop_predef: ZSTD_OptPrice_e = 1;
51pub const zop_dynamic: ZSTD_OptPrice_e = 0;
52#[repr(C)]
53pub struct ZSTD_match_t {
54    pub off: u32,
55    pub len: u32,
56}
57#[repr(C)]
58pub struct ZSTD_window_t {
59    pub nextSrc: *const u8,
60    pub base: *const u8,
61    pub dictBase: *const u8,
62    pub dictLimit: u32,
63    pub lowLimit: u32,
64    pub nbOverflowCorrections: u32,
65}
66pub type ZSTD_dictMode_e = core::ffi::c_uint;
67pub const ZSTD_dedicatedDictSearch: ZSTD_dictMode_e = 3;
68pub const ZSTD_dictMatchState: ZSTD_dictMode_e = 2;
69pub const ZSTD_extDict: ZSTD_dictMode_e = 1;
70pub const ZSTD_noDict: ZSTD_dictMode_e = 0;
71pub type searchMethod_e = core::ffi::c_uint;
72pub const search_rowHash: searchMethod_e = 2;
73pub const search_binaryTree: searchMethod_e = 1;
74pub const search_hashChain: searchMethod_e = 0;
75pub type ZSTD_VecMask = u64;
76
77use libc::size_t;
78
79use crate::lib::common::fse::{FSE_CTable, FSE_repeat};
80use crate::lib::common::huf::{HUF_CElt, HUF_repeat};
81use crate::lib::common::mem::{
82    MEM_64bits, MEM_isLittleEndian, MEM_read16, MEM_read32, MEM_readLE32, MEM_readLE64, MEM_readST,
83};
84use crate::lib::common::zstd_internal::{
85    Overlap, ZSTD_copy16, ZSTD_wildcopy, MINMATCH, WILDCOPY_OVERLENGTH, ZSTD_REP_NUM,
86};
87use crate::lib::compress::zstd_compress::{SeqStore_t, ZSTD_MatchState_t, ZSTD_optimal_t};
88use crate::lib::zstd::*;
89pub const kSearchStrength: core::ffi::c_int = 8;
90pub const ZSTD_DUBT_UNSORTED_MARK: core::ffi::c_int = 1;
91pub const ZSTD_ROW_HASH_CACHE_SIZE: core::ffi::c_int = 8;
92unsafe fn ZSTD_safecopyLiterals(
93    mut op: *mut u8,
94    mut ip: *const u8,
95    iend: *const u8,
96    ilimit_w: *const u8,
97) {
98    if ip <= ilimit_w {
99        ZSTD_wildcopy(
100            op as *mut core::ffi::c_void,
101            ip as *const core::ffi::c_void,
102            ilimit_w.offset_from(ip) as size_t,
103            Overlap::NoOverlap,
104        );
105        op = op.offset(ilimit_w.offset_from(ip) as core::ffi::c_long as isize);
106        ip = ilimit_w;
107    }
108    while ip < iend {
109        let fresh0 = ip;
110        ip = ip.offset(1);
111        let fresh1 = op;
112        op = op.offset(1);
113        *fresh1 = *fresh0;
114    }
115}
116pub const REPCODE1_TO_OFFBASE: core::ffi::c_int = 1;
117#[inline(always)]
118unsafe fn ZSTD_storeSeqOnly(
119    seqStorePtr: *mut SeqStore_t,
120    litLength: size_t,
121    offBase: u32,
122    matchLength: size_t,
123) {
124    if (litLength > 0xffff as core::ffi::c_int as size_t) as core::ffi::c_int as core::ffi::c_long
125        != 0
126    {
127        (*seqStorePtr).longLengthType = ZSTD_llt_literalLength;
128        (*seqStorePtr).longLengthPos = ((*seqStorePtr).sequences)
129            .offset_from((*seqStorePtr).sequencesStart)
130            as core::ffi::c_long as u32;
131    }
132    (*((*seqStorePtr).sequences).offset(0)).litLength = litLength as u16;
133    (*((*seqStorePtr).sequences).offset(0)).offBase = offBase;
134    let mlBase = matchLength.wrapping_sub(MINMATCH as size_t);
135    if (mlBase > 0xffff as core::ffi::c_int as size_t) as core::ffi::c_int as core::ffi::c_long != 0
136    {
137        (*seqStorePtr).longLengthType = ZSTD_llt_matchLength;
138        (*seqStorePtr).longLengthPos = ((*seqStorePtr).sequences)
139            .offset_from((*seqStorePtr).sequencesStart)
140            as core::ffi::c_long as u32;
141    }
142    (*((*seqStorePtr).sequences).offset(0)).mlBase = mlBase as u16;
143    (*seqStorePtr).sequences = ((*seqStorePtr).sequences).offset(1);
144    (*seqStorePtr).sequences;
145}
146#[inline(always)]
147unsafe fn ZSTD_storeSeq(
148    seqStorePtr: *mut SeqStore_t,
149    litLength: size_t,
150    literals: *const u8,
151    litLimit: *const u8,
152    offBase: u32,
153    matchLength: size_t,
154) {
155    let litLimit_w = litLimit.sub(WILDCOPY_OVERLENGTH);
156    let litEnd = literals.add(litLength);
157    if litEnd <= litLimit_w {
158        ZSTD_copy16(
159            (*seqStorePtr).lit as *mut core::ffi::c_void,
160            literals as *const core::ffi::c_void,
161        );
162        if litLength > 16 {
163            ZSTD_wildcopy(
164                ((*seqStorePtr).lit).offset(16) as *mut core::ffi::c_void,
165                literals.offset(16) as *const core::ffi::c_void,
166                litLength.wrapping_sub(16),
167                Overlap::NoOverlap,
168            );
169        }
170    } else {
171        ZSTD_safecopyLiterals((*seqStorePtr).lit, literals, litEnd, litLimit_w);
172    }
173    (*seqStorePtr).lit = ((*seqStorePtr).lit).add(litLength);
174    ZSTD_storeSeqOnly(seqStorePtr, litLength, offBase, matchLength);
175}
176#[inline]
177unsafe fn ZSTD_count(mut pIn: *const u8, mut pMatch: *const u8, pInLimit: *const u8) -> size_t {
178    let pStart = pIn;
179    let pInLoopLimit = pInLimit.offset(
180        -((::core::mem::size_of::<size_t>() as core::ffi::c_ulong).wrapping_sub(1) as isize),
181    );
182    if pIn < pInLoopLimit {
183        let diff = MEM_readST(pMatch as *const core::ffi::c_void)
184            ^ MEM_readST(pIn as *const core::ffi::c_void);
185        if diff != 0 {
186            return ZSTD_NbCommonBytes(diff) as size_t;
187        }
188        pIn = pIn.offset(::core::mem::size_of::<size_t>() as core::ffi::c_ulong as isize);
189        pMatch = pMatch.offset(::core::mem::size_of::<size_t>() as core::ffi::c_ulong as isize);
190        while pIn < pInLoopLimit {
191            let diff_0 = MEM_readST(pMatch as *const core::ffi::c_void)
192                ^ MEM_readST(pIn as *const core::ffi::c_void);
193            if diff_0 == 0 {
194                pIn = pIn.offset(::core::mem::size_of::<size_t>() as core::ffi::c_ulong as isize);
195                pMatch =
196                    pMatch.offset(::core::mem::size_of::<size_t>() as core::ffi::c_ulong as isize);
197            } else {
198                pIn = pIn.offset(ZSTD_NbCommonBytes(diff_0) as isize);
199                return pIn.offset_from(pStart) as size_t;
200            }
201        }
202    }
203    if MEM_64bits() != 0
204        && pIn < pInLimit.offset(-(3))
205        && MEM_read32(pMatch as *const core::ffi::c_void)
206            == MEM_read32(pIn as *const core::ffi::c_void)
207    {
208        pIn = pIn.offset(4);
209        pMatch = pMatch.offset(4);
210    }
211    if pIn < pInLimit.offset(-(1))
212        && MEM_read16(pMatch as *const core::ffi::c_void) as core::ffi::c_int
213            == MEM_read16(pIn as *const core::ffi::c_void) as core::ffi::c_int
214    {
215        pIn = pIn.offset(2);
216        pMatch = pMatch.offset(2);
217    }
218    if pIn < pInLimit && *pMatch as core::ffi::c_int == *pIn as core::ffi::c_int {
219        pIn = pIn.offset(1);
220    }
221    pIn.offset_from(pStart) as size_t
222}
223#[inline]
224unsafe fn ZSTD_count_2segments(
225    ip: *const u8,
226    match_0: *const u8,
227    iEnd: *const u8,
228    mEnd: *const u8,
229    iStart: *const u8,
230) -> size_t {
231    let vEnd = if ip.offset(mEnd.offset_from(match_0) as core::ffi::c_long as isize) < iEnd {
232        ip.offset(mEnd.offset_from(match_0) as core::ffi::c_long as isize)
233    } else {
234        iEnd
235    };
236    let matchLength = ZSTD_count(ip, match_0, vEnd);
237    if match_0.add(matchLength) != mEnd {
238        return matchLength;
239    }
240    matchLength.wrapping_add(ZSTD_count(ip.add(matchLength), iStart, iEnd))
241}
242static prime4bytes: u32 = 2654435761;
243unsafe fn ZSTD_hash4(u: u32, h: u32, s: u32) -> u32 {
244    ((u * prime4bytes) ^ s) >> 32u32.wrapping_sub(h)
245}
246unsafe fn ZSTD_hash4Ptr(ptr: *const core::ffi::c_void, h: u32) -> size_t {
247    ZSTD_hash4(MEM_readLE32(ptr), h, 0) as size_t
248}
249unsafe fn ZSTD_hash4PtrS(ptr: *const core::ffi::c_void, h: u32, s: u32) -> size_t {
250    ZSTD_hash4(MEM_readLE32(ptr), h, s) as size_t
251}
252static prime5bytes: u64 = 889523592379;
253unsafe fn ZSTD_hash5(u: u64, h: u32, s: u64) -> size_t {
254    ((((u << (64 - 40)) * prime5bytes) ^ s) >> 64u32.wrapping_sub(h)) as size_t
255}
256unsafe fn ZSTD_hash5Ptr(p: *const core::ffi::c_void, h: u32) -> size_t {
257    ZSTD_hash5(MEM_readLE64(p), h, 0)
258}
259unsafe fn ZSTD_hash5PtrS(p: *const core::ffi::c_void, h: u32, s: u64) -> size_t {
260    ZSTD_hash5(MEM_readLE64(p), h, s)
261}
262static prime6bytes: u64 = 227718039650203;
263unsafe fn ZSTD_hash6(u: u64, h: u32, s: u64) -> size_t {
264    ((((u << (64 - 48)) * prime6bytes) ^ s) >> 64u32.wrapping_sub(h)) as size_t
265}
266unsafe fn ZSTD_hash6Ptr(p: *const core::ffi::c_void, h: u32) -> size_t {
267    ZSTD_hash6(MEM_readLE64(p), h, 0)
268}
269unsafe fn ZSTD_hash6PtrS(p: *const core::ffi::c_void, h: u32, s: u64) -> size_t {
270    ZSTD_hash6(MEM_readLE64(p), h, s)
271}
272static prime7bytes: u64 = 58295818150454627;
273unsafe fn ZSTD_hash7(u: u64, h: u32, s: u64) -> size_t {
274    ((((u << (64 - 56)) * prime7bytes) ^ s) >> 64u32.wrapping_sub(h)) as size_t
275}
276unsafe fn ZSTD_hash7Ptr(p: *const core::ffi::c_void, h: u32) -> size_t {
277    ZSTD_hash7(MEM_readLE64(p), h, 0)
278}
279unsafe fn ZSTD_hash7PtrS(p: *const core::ffi::c_void, h: u32, s: u64) -> size_t {
280    ZSTD_hash7(MEM_readLE64(p), h, s)
281}
282static prime8bytes: u64 = 0xcf1bbcdcb7a56463 as core::ffi::c_ulonglong;
283unsafe fn ZSTD_hash8(u: u64, h: u32, s: u64) -> size_t {
284    (((u * prime8bytes) ^ s) >> 64u32.wrapping_sub(h)) as size_t
285}
286unsafe fn ZSTD_hash8Ptr(p: *const core::ffi::c_void, h: u32) -> size_t {
287    ZSTD_hash8(MEM_readLE64(p), h, 0)
288}
289unsafe fn ZSTD_hash8PtrS(p: *const core::ffi::c_void, h: u32, s: u64) -> size_t {
290    ZSTD_hash8(MEM_readLE64(p), h, s)
291}
292#[inline(always)]
293unsafe fn ZSTD_hashPtr(p: *const core::ffi::c_void, hBits: u32, mls: u32) -> size_t {
294    match mls {
295        5 => ZSTD_hash5Ptr(p, hBits),
296        6 => ZSTD_hash6Ptr(p, hBits),
297        7 => ZSTD_hash7Ptr(p, hBits),
298        8 => ZSTD_hash8Ptr(p, hBits),
299        4 | _ => ZSTD_hash4Ptr(p, hBits),
300    }
301}
302#[inline(always)]
303unsafe fn ZSTD_hashPtrSalted(
304    p: *const core::ffi::c_void,
305    hBits: u32,
306    mls: u32,
307    hashSalt: u64,
308) -> size_t {
309    match mls {
310        5 => ZSTD_hash5PtrS(p, hBits, hashSalt),
311        6 => ZSTD_hash6PtrS(p, hBits, hashSalt),
312        7 => ZSTD_hash7PtrS(p, hBits, hashSalt),
313        8 => ZSTD_hash8PtrS(p, hBits, hashSalt),
314        4 | _ => ZSTD_hash4PtrS(p, hBits, hashSalt as u32),
315    }
316}
317#[inline]
318unsafe fn ZSTD_getLowestMatchIndex(
319    ms: *const ZSTD_MatchState_t,
320    curr: u32,
321    windowLog: core::ffi::c_uint,
322) -> u32 {
323    let maxDistance = (1) << windowLog;
324    let lowestValid = (*ms).window.lowLimit;
325    let withinWindow = if curr.wrapping_sub(lowestValid) > maxDistance {
326        curr.wrapping_sub(maxDistance)
327    } else {
328        lowestValid
329    };
330    let isDictionary = ((*ms).loadedDictEnd != 0) as core::ffi::c_int as u32;
331
332    if isDictionary != 0 {
333        lowestValid
334    } else {
335        withinWindow
336    }
337}
338#[inline]
339unsafe fn ZSTD_getLowestPrefixIndex(
340    ms: *const ZSTD_MatchState_t,
341    curr: u32,
342    windowLog: core::ffi::c_uint,
343) -> u32 {
344    let maxDistance = (1) << windowLog;
345    let lowestValid = (*ms).window.dictLimit;
346    let withinWindow = if curr.wrapping_sub(lowestValid) > maxDistance {
347        curr.wrapping_sub(maxDistance)
348    } else {
349        lowestValid
350    };
351    let isDictionary = ((*ms).loadedDictEnd != 0) as core::ffi::c_int as u32;
352
353    if isDictionary != 0 {
354        lowestValid
355    } else {
356        withinWindow
357    }
358}
359#[inline]
360unsafe fn ZSTD_index_overlap_check(prefixLowestIndex: u32, repIndex: u32) -> core::ffi::c_int {
361    (prefixLowestIndex.wrapping_sub(1).wrapping_sub(repIndex) >= 3) as core::ffi::c_int
362}
363#[inline]
364unsafe fn ZSTD_countTrailingZeros32(val: u32) -> core::ffi::c_uint {
365    val.trailing_zeros() as i32 as core::ffi::c_uint
366}
367#[inline]
368unsafe fn ZSTD_countLeadingZeros32(val: u32) -> core::ffi::c_uint {
369    val.leading_zeros() as i32 as core::ffi::c_uint
370}
371#[inline]
372unsafe fn ZSTD_countTrailingZeros64(val: u64) -> core::ffi::c_uint {
373    (val as core::ffi::c_ulonglong).trailing_zeros() as i32 as core::ffi::c_uint
374}
375#[inline]
376unsafe fn ZSTD_countLeadingZeros64(val: u64) -> core::ffi::c_uint {
377    (val as core::ffi::c_ulonglong).leading_zeros() as i32 as core::ffi::c_uint
378}
379#[inline]
380unsafe fn ZSTD_NbCommonBytes(val: size_t) -> core::ffi::c_uint {
381    if MEM_isLittleEndian() != 0 {
382        if MEM_64bits() != 0 {
383            ZSTD_countTrailingZeros64(val as u64) >> 3
384        } else {
385            ZSTD_countTrailingZeros32(val as u32) >> 3
386        }
387    } else if MEM_64bits() != 0 {
388        ZSTD_countLeadingZeros64(val as u64) >> 3
389    } else {
390        ZSTD_countLeadingZeros32(val as u32) >> 3
391    }
392}
393#[inline]
394unsafe fn ZSTD_highbit32(val: u32) -> core::ffi::c_uint {
395    (31 as core::ffi::c_uint).wrapping_sub(ZSTD_countLeadingZeros32(val))
396}
397#[inline]
398unsafe fn ZSTD_rotateRight_U64(value: u64, mut count: u32) -> u64 {
399    count &= 0x3f as core::ffi::c_int as u32;
400    value >> count
401        | value << ((0 as core::ffi::c_uint).wrapping_sub(count) & 0x3f as core::ffi::c_uint)
402}
403#[inline]
404unsafe fn ZSTD_rotateRight_U32(value: u32, mut count: u32) -> u32 {
405    count &= 0x1f as core::ffi::c_int as u32;
406    value >> count
407        | value << ((0 as core::ffi::c_uint).wrapping_sub(count) & 0x1f as core::ffi::c_uint)
408}
409#[inline]
410unsafe fn ZSTD_rotateRight_U16(value: u16, mut count: u32) -> u16 {
411    count &= 0xf as core::ffi::c_int as u32;
412    (value as core::ffi::c_int >> count
413        | ((value as core::ffi::c_int)
414            << ((0 as core::ffi::c_uint).wrapping_sub(count) & 0xf as core::ffi::c_uint))
415            as u16 as core::ffi::c_int) as u16
416}
417pub const ZSTD_LAZY_DDSS_BUCKET_LOG: core::ffi::c_int = 2;
418pub const ZSTD_ROW_HASH_TAG_BITS: core::ffi::c_int = 8;
419pub const kLazySkippingStep: core::ffi::c_int = 8;
420unsafe fn ZSTD_updateDUBT(ms: *mut ZSTD_MatchState_t, ip: *const u8, iend: *const u8, mls: u32) {
421    let cParams: *const ZSTD_compressionParameters = &mut (*ms).cParams;
422    let hashTable = (*ms).hashTable;
423    let hashLog = (*cParams).hashLog;
424    let bt = (*ms).chainTable;
425    let btLog = ((*cParams).chainLog).wrapping_sub(1);
426    let btMask = (((1) << btLog) - 1) as u32;
427    let base = (*ms).window.base;
428    let target = ip.offset_from(base) as core::ffi::c_long as u32;
429    let mut idx = (*ms).nextToUpdate;
430    idx != target;
431    while idx < target {
432        let h = ZSTD_hashPtr(
433            base.offset(idx as isize) as *const core::ffi::c_void,
434            hashLog,
435            mls,
436        );
437        let matchIndex = *hashTable.add(h);
438        let nextCandidatePtr = bt.offset((2 * (idx & btMask)) as isize);
439        let sortMarkPtr = nextCandidatePtr.offset(1);
440        *hashTable.add(h) = idx;
441        *nextCandidatePtr = matchIndex;
442        *sortMarkPtr = ZSTD_DUBT_UNSORTED_MARK as u32;
443        idx = idx.wrapping_add(1);
444    }
445    (*ms).nextToUpdate = target;
446}
447unsafe fn ZSTD_insertDUBT1(
448    ms: *const ZSTD_MatchState_t,
449    curr: u32,
450    inputEnd: *const u8,
451    mut nbCompares: u32,
452    btLow: u32,
453    dictMode: ZSTD_dictMode_e,
454) {
455    let cParams: *const ZSTD_compressionParameters = &(*ms).cParams;
456    let bt = (*ms).chainTable;
457    let btLog = ((*cParams).chainLog).wrapping_sub(1);
458    let btMask = (((1) << btLog) - 1) as u32;
459    let mut commonLengthSmaller = 0;
460    let mut commonLengthLarger = 0;
461    let base = (*ms).window.base;
462    let dictBase = (*ms).window.dictBase;
463    let dictLimit = (*ms).window.dictLimit;
464    let ip = if curr >= dictLimit {
465        base.offset(curr as isize)
466    } else {
467        dictBase.offset(curr as isize)
468    };
469    let iend = if curr >= dictLimit {
470        inputEnd
471    } else {
472        dictBase.offset(dictLimit as isize)
473    };
474    let dictEnd = dictBase.offset(dictLimit as isize);
475    let prefixStart = base.offset(dictLimit as isize);
476    let mut match_0 = core::ptr::null::<u8>();
477    let mut smallerPtr = bt.offset((2 * (curr & btMask)) as isize);
478    let mut largerPtr = smallerPtr.offset(1);
479    let mut matchIndex = *smallerPtr;
480    let mut dummy32: u32 = 0;
481    let windowValid = (*ms).window.lowLimit;
482    let maxDistance = (1) << (*cParams).windowLog;
483    let windowLow = if curr.wrapping_sub(windowValid) > maxDistance {
484        curr.wrapping_sub(maxDistance)
485    } else {
486        windowValid
487    };
488    while nbCompares != 0 && matchIndex > windowLow {
489        let nextPtr = bt.offset((2 * (matchIndex & btMask)) as isize);
490        let mut matchLength = if commonLengthSmaller < commonLengthLarger {
491            commonLengthSmaller
492        } else {
493            commonLengthLarger
494        };
495        if dictMode as core::ffi::c_uint != ZSTD_extDict as core::ffi::c_int as core::ffi::c_uint
496            || (matchIndex as size_t).wrapping_add(matchLength) >= dictLimit as size_t
497            || curr < dictLimit
498        {
499            let mBase = if dictMode as core::ffi::c_uint
500                != ZSTD_extDict as core::ffi::c_int as core::ffi::c_uint
501                || (matchIndex as size_t).wrapping_add(matchLength) >= dictLimit as size_t
502            {
503                base
504            } else {
505                dictBase
506            };
507            match_0 = mBase.offset(matchIndex as isize);
508            matchLength = matchLength.wrapping_add(ZSTD_count(
509                ip.add(matchLength),
510                match_0.add(matchLength),
511                iend,
512            ));
513        } else {
514            match_0 = dictBase.offset(matchIndex as isize);
515            matchLength = matchLength.wrapping_add(ZSTD_count_2segments(
516                ip.add(matchLength),
517                match_0.add(matchLength),
518                iend,
519                dictEnd,
520                prefixStart,
521            ));
522            if (matchIndex as size_t).wrapping_add(matchLength) >= dictLimit as size_t {
523                match_0 = base.offset(matchIndex as isize);
524            }
525        }
526        if ip.add(matchLength) == iend {
527            break;
528        } else {
529            if (*match_0.add(matchLength) as core::ffi::c_int)
530                < *ip.add(matchLength) as core::ffi::c_int
531            {
532                *smallerPtr = matchIndex;
533                commonLengthSmaller = matchLength;
534                if matchIndex <= btLow {
535                    smallerPtr = &mut dummy32;
536                    break;
537                } else {
538                    smallerPtr = nextPtr.offset(1);
539                    matchIndex = *nextPtr.offset(1);
540                }
541            } else {
542                *largerPtr = matchIndex;
543                commonLengthLarger = matchLength;
544                if matchIndex <= btLow {
545                    largerPtr = &mut dummy32;
546                    break;
547                } else {
548                    largerPtr = nextPtr;
549                    matchIndex = *nextPtr.offset(0);
550                }
551            }
552            nbCompares = nbCompares.wrapping_sub(1);
553        }
554    }
555    *largerPtr = 0;
556    *smallerPtr = *largerPtr;
557}
558unsafe fn ZSTD_DUBT_findBetterDictMatch(
559    ms: *const ZSTD_MatchState_t,
560    ip: *const u8,
561    iend: *const u8,
562    offsetPtr: *mut size_t,
563    mut bestLength: size_t,
564    mut nbCompares: u32,
565    mls: u32,
566    dictMode: ZSTD_dictMode_e,
567) -> size_t {
568    let dms = (*ms).dictMatchState;
569    let dmsCParams: *const ZSTD_compressionParameters = &(*dms).cParams;
570    let dictHashTable: *const u32 = (*dms).hashTable;
571    let hashLog = (*dmsCParams).hashLog;
572    let h = ZSTD_hashPtr(ip as *const core::ffi::c_void, hashLog, mls);
573    let mut dictMatchIndex = *dictHashTable.add(h);
574    let base = (*ms).window.base;
575    let prefixStart = base.offset((*ms).window.dictLimit as isize);
576    let curr = ip.offset_from(base) as core::ffi::c_long as u32;
577    let dictBase = (*dms).window.base;
578    let dictEnd = (*dms).window.nextSrc;
579    let dictHighLimit =
580        ((*dms).window.nextSrc).offset_from((*dms).window.base) as core::ffi::c_long as u32;
581    let dictLowLimit = (*dms).window.lowLimit;
582    let dictIndexDelta = ((*ms).window.lowLimit).wrapping_sub(dictHighLimit);
583    let dictBt = (*dms).chainTable;
584    let btLog = ((*dmsCParams).chainLog).wrapping_sub(1);
585    let btMask = (((1) << btLog) - 1) as u32;
586    let btLow = if btMask >= dictHighLimit.wrapping_sub(dictLowLimit) {
587        dictLowLimit
588    } else {
589        dictHighLimit.wrapping_sub(btMask)
590    };
591    let mut commonLengthSmaller = 0 as size_t;
592    let mut commonLengthLarger = 0 as size_t;
593    while nbCompares != 0 && dictMatchIndex > dictLowLimit {
594        let nextPtr = dictBt.offset((2 * (dictMatchIndex & btMask)) as isize);
595        let mut matchLength = if commonLengthSmaller < commonLengthLarger {
596            commonLengthSmaller
597        } else {
598            commonLengthLarger
599        };
600        let mut match_0 = dictBase.offset(dictMatchIndex as isize);
601        matchLength = matchLength.wrapping_add(ZSTD_count_2segments(
602            ip.add(matchLength),
603            match_0.add(matchLength),
604            iend,
605            dictEnd,
606            prefixStart,
607        ));
608        if (dictMatchIndex as size_t).wrapping_add(matchLength) >= dictHighLimit as size_t {
609            match_0 = base
610                .offset(dictMatchIndex as isize)
611                .offset(dictIndexDelta as isize);
612        }
613        if matchLength > bestLength {
614            let matchIndex = dictMatchIndex.wrapping_add(dictIndexDelta);
615            if 4 * matchLength.wrapping_sub(bestLength) as core::ffi::c_int
616                > (ZSTD_highbit32(curr.wrapping_sub(matchIndex).wrapping_add(1))).wrapping_sub(
617                    ZSTD_highbit32((*offsetPtr.offset(0) as u32).wrapping_add(1)),
618                ) as core::ffi::c_int
619            {
620                bestLength = matchLength;
621                *offsetPtr = curr
622                    .wrapping_sub(matchIndex)
623                    .wrapping_add(ZSTD_REP_NUM as u32) as size_t;
624            }
625            if ip.add(matchLength) == iend {
626                break;
627            }
628        }
629        if (*match_0.add(matchLength) as core::ffi::c_int)
630            < *ip.add(matchLength) as core::ffi::c_int
631        {
632            if dictMatchIndex <= btLow {
633                break;
634            }
635            commonLengthSmaller = matchLength;
636            dictMatchIndex = *nextPtr.offset(1);
637        } else {
638            if dictMatchIndex <= btLow {
639                break;
640            }
641            commonLengthLarger = matchLength;
642            dictMatchIndex = *nextPtr.offset(0);
643        }
644        nbCompares = nbCompares.wrapping_sub(1);
645    }
646    if bestLength >= MINMATCH as size_t {
647        let mIndex = curr.wrapping_sub((*offsetPtr).wrapping_sub(ZSTD_REP_NUM as size_t) as u32);
648    }
649    bestLength
650}
651unsafe fn ZSTD_DUBT_findBestMatch(
652    ms: *mut ZSTD_MatchState_t,
653    ip: *const u8,
654    iend: *const u8,
655    offBasePtr: *mut size_t,
656    mls: u32,
657    dictMode: ZSTD_dictMode_e,
658) -> size_t {
659    let cParams: *const ZSTD_compressionParameters = &mut (*ms).cParams;
660    let hashTable = (*ms).hashTable;
661    let hashLog = (*cParams).hashLog;
662    let h = ZSTD_hashPtr(ip as *const core::ffi::c_void, hashLog, mls);
663    let mut matchIndex = *hashTable.add(h);
664    let base = (*ms).window.base;
665    let curr = ip.offset_from(base) as core::ffi::c_long as u32;
666    let windowLow = ZSTD_getLowestMatchIndex(ms, curr, (*cParams).windowLog);
667    let bt = (*ms).chainTable;
668    let btLog = ((*cParams).chainLog).wrapping_sub(1);
669    let btMask = (((1) << btLog) - 1) as u32;
670    let btLow = if btMask >= curr {
671        0
672    } else {
673        curr.wrapping_sub(btMask)
674    };
675    let unsortLimit = if btLow > windowLow { btLow } else { windowLow };
676    let mut nextCandidate = bt.offset((2 * (matchIndex & btMask)) as isize);
677    let mut unsortedMark = bt.offset((2 * (matchIndex & btMask)) as isize).offset(1);
678    let mut nbCompares = (1 as core::ffi::c_uint) << (*cParams).searchLog;
679    let mut nbCandidates = nbCompares;
680    let mut previousCandidate = 0;
681    while matchIndex > unsortLimit
682        && *unsortedMark == ZSTD_DUBT_UNSORTED_MARK as u32
683        && nbCandidates > 1
684    {
685        *unsortedMark = previousCandidate;
686        previousCandidate = matchIndex;
687        matchIndex = *nextCandidate;
688        nextCandidate = bt.offset((2 * (matchIndex & btMask)) as isize);
689        unsortedMark = bt.offset((2 * (matchIndex & btMask)) as isize).offset(1);
690        nbCandidates = nbCandidates.wrapping_sub(1);
691    }
692    if matchIndex > unsortLimit && *unsortedMark == ZSTD_DUBT_UNSORTED_MARK as u32 {
693        *unsortedMark = 0;
694        *nextCandidate = *unsortedMark;
695    }
696    matchIndex = previousCandidate;
697    while matchIndex != 0 {
698        let nextCandidateIdxPtr = bt.offset((2 * (matchIndex & btMask)) as isize).offset(1);
699        let nextCandidateIdx = *nextCandidateIdxPtr;
700        ZSTD_insertDUBT1(ms, matchIndex, iend, nbCandidates, unsortLimit, dictMode);
701        matchIndex = nextCandidateIdx;
702        nbCandidates = nbCandidates.wrapping_add(1);
703    }
704    let mut commonLengthSmaller = 0;
705    let mut commonLengthLarger = 0;
706    let dictBase = (*ms).window.dictBase;
707    let dictLimit = (*ms).window.dictLimit;
708    let dictEnd = dictBase.offset(dictLimit as isize);
709    let prefixStart = base.offset(dictLimit as isize);
710    let mut smallerPtr = bt.offset((2 * (curr & btMask)) as isize);
711    let mut largerPtr = bt.offset((2 * (curr & btMask)) as isize).offset(1);
712    let mut matchEndIdx = curr.wrapping_add(8).wrapping_add(1);
713    let mut dummy32: u32 = 0;
714    let mut bestLength = 0;
715    matchIndex = *hashTable.add(h);
716    *hashTable.add(h) = curr;
717    while nbCompares != 0 && matchIndex > windowLow {
718        let nextPtr = bt.offset((2 * (matchIndex & btMask)) as isize);
719        let mut matchLength = if commonLengthSmaller < commonLengthLarger {
720            commonLengthSmaller
721        } else {
722            commonLengthLarger
723        };
724        let mut match_0 = core::ptr::null::<u8>();
725        if dictMode as core::ffi::c_uint != ZSTD_extDict as core::ffi::c_int as core::ffi::c_uint
726            || (matchIndex as size_t).wrapping_add(matchLength) >= dictLimit as size_t
727        {
728            match_0 = base.offset(matchIndex as isize);
729            matchLength = matchLength.wrapping_add(ZSTD_count(
730                ip.add(matchLength),
731                match_0.add(matchLength),
732                iend,
733            ));
734        } else {
735            match_0 = dictBase.offset(matchIndex as isize);
736            matchLength = matchLength.wrapping_add(ZSTD_count_2segments(
737                ip.add(matchLength),
738                match_0.add(matchLength),
739                iend,
740                dictEnd,
741                prefixStart,
742            ));
743            if (matchIndex as size_t).wrapping_add(matchLength) >= dictLimit as size_t {
744                match_0 = base.offset(matchIndex as isize);
745            }
746        }
747        if matchLength > bestLength {
748            if matchLength > matchEndIdx.wrapping_sub(matchIndex) as size_t {
749                matchEndIdx = matchIndex.wrapping_add(matchLength as u32);
750            }
751            if 4 * matchLength.wrapping_sub(bestLength) as core::ffi::c_int
752                > (ZSTD_highbit32(curr.wrapping_sub(matchIndex).wrapping_add(1)))
753                    .wrapping_sub(ZSTD_highbit32(*offBasePtr as u32))
754                    as core::ffi::c_int
755            {
756                bestLength = matchLength;
757                *offBasePtr = curr
758                    .wrapping_sub(matchIndex)
759                    .wrapping_add(ZSTD_REP_NUM as u32) as size_t;
760            }
761            if ip.add(matchLength) == iend {
762                if dictMode as core::ffi::c_uint
763                    == ZSTD_dictMatchState as core::ffi::c_int as core::ffi::c_uint
764                {
765                    nbCompares = 0;
766                }
767                break;
768            }
769        }
770        if (*match_0.add(matchLength) as core::ffi::c_int)
771            < *ip.add(matchLength) as core::ffi::c_int
772        {
773            *smallerPtr = matchIndex;
774            commonLengthSmaller = matchLength;
775            if matchIndex <= btLow {
776                smallerPtr = &mut dummy32;
777                break;
778            } else {
779                smallerPtr = nextPtr.offset(1);
780                matchIndex = *nextPtr.offset(1);
781            }
782        } else {
783            *largerPtr = matchIndex;
784            commonLengthLarger = matchLength;
785            if matchIndex <= btLow {
786                largerPtr = &mut dummy32;
787                break;
788            } else {
789                largerPtr = nextPtr;
790                matchIndex = *nextPtr.offset(0);
791            }
792        }
793        nbCompares = nbCompares.wrapping_sub(1);
794    }
795    *largerPtr = 0;
796    *smallerPtr = *largerPtr;
797    if dictMode as core::ffi::c_uint == ZSTD_dictMatchState as core::ffi::c_int as core::ffi::c_uint
798        && nbCompares != 0
799    {
800        bestLength = ZSTD_DUBT_findBetterDictMatch(
801            ms, ip, iend, offBasePtr, bestLength, nbCompares, mls, dictMode,
802        );
803    }
804    (*ms).nextToUpdate = matchEndIdx.wrapping_sub(8);
805    if bestLength >= MINMATCH as size_t {
806        let mIndex = curr.wrapping_sub((*offBasePtr).wrapping_sub(ZSTD_REP_NUM as size_t) as u32);
807    }
808    bestLength
809}
810#[inline(always)]
811unsafe fn ZSTD_BtFindBestMatch(
812    ms: *mut ZSTD_MatchState_t,
813    ip: *const u8,
814    iLimit: *const u8,
815    offBasePtr: *mut size_t,
816    mls: u32,
817    dictMode: ZSTD_dictMode_e,
818) -> size_t {
819    if ip < ((*ms).window.base).offset((*ms).nextToUpdate as isize) {
820        return 0;
821    }
822    ZSTD_updateDUBT(ms, ip, iLimit, mls);
823    ZSTD_DUBT_findBestMatch(ms, ip, iLimit, offBasePtr, mls, dictMode)
824}
825pub unsafe fn ZSTD_dedicatedDictSearch_lazy_loadDictionary(
826    ms: *mut ZSTD_MatchState_t,
827    ip: *const u8,
828) {
829    let base = (*ms).window.base;
830    let target = ip.offset_from(base) as core::ffi::c_long as u32;
831    let hashTable = (*ms).hashTable;
832    let chainTable = (*ms).chainTable;
833    let chainSize = ((1) << (*ms).cParams.chainLog) as u32;
834    let mut idx = (*ms).nextToUpdate;
835    let minChain = if chainSize < target.wrapping_sub(idx) {
836        target.wrapping_sub(chainSize)
837    } else {
838        idx
839    };
840    let bucketSize = ((1) << ZSTD_LAZY_DDSS_BUCKET_LOG) as u32;
841    let cacheSize = bucketSize.wrapping_sub(1);
842    let chainAttempts = (((1) << (*ms).cParams.searchLog) as u32).wrapping_sub(cacheSize);
843    let chainLimit = if chainAttempts > 255 {
844        255
845    } else {
846        chainAttempts
847    };
848    let hashLog =
849        ((*ms).cParams.hashLog).wrapping_sub(ZSTD_LAZY_DDSS_BUCKET_LOG as core::ffi::c_uint);
850    let tmpHashTable = hashTable;
851    let tmpChainTable = hashTable.offset(((1) << hashLog) as isize);
852    let tmpChainSize = ((((1) << ZSTD_LAZY_DDSS_BUCKET_LOG) - 1) as u32) << hashLog;
853    let tmpMinChain = if tmpChainSize < target {
854        target.wrapping_sub(tmpChainSize)
855    } else {
856        idx
857    };
858    let mut hashIdx: u32 = 0;
859    while idx < target {
860        let h = ZSTD_hashPtr(
861            base.offset(idx as isize) as *const core::ffi::c_void,
862            hashLog,
863            (*ms).cParams.minMatch,
864        ) as u32;
865        if idx >= tmpMinChain {
866            *tmpChainTable.offset(idx.wrapping_sub(tmpMinChain) as isize) =
867                *hashTable.offset(h as isize);
868        }
869        *tmpHashTable.offset(h as isize) = idx;
870        idx = idx.wrapping_add(1);
871    }
872    let mut chainPos = 0u32;
873    hashIdx = 0;
874    while hashIdx < (1) << hashLog {
875        let mut count: u32 = 0;
876        let mut countBeyondMinChain = 0u32;
877        let mut i = *tmpHashTable.offset(hashIdx as isize);
878        count = 0;
879        while i >= tmpMinChain && count < cacheSize {
880            if i < minChain {
881                countBeyondMinChain = countBeyondMinChain.wrapping_add(1);
882            }
883            i = *tmpChainTable.offset(i.wrapping_sub(tmpMinChain) as isize);
884            count = count.wrapping_add(1);
885        }
886        if count == cacheSize {
887            count = 0;
888            while count < chainLimit {
889                if i < minChain
890                    && (i == 0 || {
891                        countBeyondMinChain = countBeyondMinChain.wrapping_add(1);
892                        countBeyondMinChain > cacheSize
893                    })
894                {
895                    break;
896                }
897                let fresh2 = chainPos;
898                chainPos = chainPos.wrapping_add(1);
899                *chainTable.offset(fresh2 as isize) = i;
900                count = count.wrapping_add(1);
901                if i < tmpMinChain {
902                    break;
903                }
904                i = *tmpChainTable.offset(i.wrapping_sub(tmpMinChain) as isize);
905            }
906        } else {
907            count = 0;
908        }
909        if count != 0 {
910            *tmpHashTable.offset(hashIdx as isize) =
911                (chainPos.wrapping_sub(count) << 8).wrapping_add(count);
912        } else {
913            *tmpHashTable.offset(hashIdx as isize) = 0;
914        }
915        hashIdx = hashIdx.wrapping_add(1);
916    }
917    hashIdx = ((1) << hashLog) as u32;
918    while hashIdx != 0 {
919        hashIdx = hashIdx.wrapping_sub(1);
920        let bucketIdx = hashIdx << ZSTD_LAZY_DDSS_BUCKET_LOG;
921        let chainPackedPointer = *tmpHashTable.offset(hashIdx as isize);
922        let mut i_0: u32 = 0;
923        i_0 = 0;
924        while i_0 < cacheSize {
925            *hashTable.offset(bucketIdx.wrapping_add(i_0) as isize) = 0;
926            i_0 = i_0.wrapping_add(1);
927        }
928        *hashTable.offset(bucketIdx.wrapping_add(bucketSize).wrapping_sub(1) as isize) =
929            chainPackedPointer;
930    }
931    idx = (*ms).nextToUpdate;
932    while idx < target {
933        let h_0 = (ZSTD_hashPtr(
934            base.offset(idx as isize) as *const core::ffi::c_void,
935            hashLog,
936            (*ms).cParams.minMatch,
937        ) as u32)
938            << ZSTD_LAZY_DDSS_BUCKET_LOG;
939        let mut i_1: u32 = 0;
940        i_1 = cacheSize.wrapping_sub(1);
941        while i_1 != 0 {
942            *hashTable.offset(h_0.wrapping_add(i_1) as isize) =
943                *hashTable.offset(h_0.wrapping_add(i_1).wrapping_sub(1) as isize);
944            i_1 = i_1.wrapping_sub(1);
945        }
946        *hashTable.offset(h_0 as isize) = idx;
947        idx = idx.wrapping_add(1);
948    }
949    (*ms).nextToUpdate = target;
950}
951#[inline(always)]
952unsafe fn ZSTD_dedicatedDictSearch_lazy_search(
953    offsetPtr: *mut size_t,
954    mut ml: size_t,
955    nbAttempts: u32,
956    dms: *const ZSTD_MatchState_t,
957    ip: *const u8,
958    iLimit: *const u8,
959    prefixStart: *const u8,
960    curr: u32,
961    dictLimit: u32,
962    ddsIdx: size_t,
963) -> size_t {
964    let ddsLowestIndex = (*dms).window.dictLimit;
965    let ddsBase = (*dms).window.base;
966    let ddsEnd = (*dms).window.nextSrc;
967    let ddsSize = ddsEnd.offset_from(ddsBase) as core::ffi::c_long as u32;
968    let ddsIndexDelta = dictLimit.wrapping_sub(ddsSize);
969    let bucketSize = ((1) << ZSTD_LAZY_DDSS_BUCKET_LOG) as u32;
970    let bucketLimit = if nbAttempts < bucketSize.wrapping_sub(1) {
971        nbAttempts
972    } else {
973        bucketSize.wrapping_sub(1)
974    };
975    let mut ddsAttempt: u32 = 0;
976    let mut matchIndex: u32 = 0;
977    ddsAttempt = 0;
978    while ddsAttempt < bucketSize.wrapping_sub(1) {
979        ddsAttempt = ddsAttempt.wrapping_add(1);
980    }
981    let chainPackedPointer =
982        *((*dms).hashTable).add(ddsIdx.wrapping_add(bucketSize as size_t).wrapping_sub(1));
983    let chainIndex = chainPackedPointer >> 8;
984    ((*dms).chainTable).offset(chainIndex as isize);
985    ddsAttempt = 0;
986    while ddsAttempt < bucketLimit {
987        let mut currentMl = 0;
988        let mut match_0 = core::ptr::null::<u8>();
989        matchIndex = *((*dms).hashTable).add(ddsIdx.wrapping_add(ddsAttempt as size_t));
990        match_0 = ddsBase.offset(matchIndex as isize);
991        if matchIndex == 0 {
992            return ml;
993        }
994        if MEM_read32(match_0 as *const core::ffi::c_void)
995            == MEM_read32(ip as *const core::ffi::c_void)
996        {
997            currentMl = (ZSTD_count_2segments(
998                ip.offset(4),
999                match_0.offset(4),
1000                iLimit,
1001                ddsEnd,
1002                prefixStart,
1003            ))
1004            .wrapping_add(4);
1005        }
1006        if currentMl > ml {
1007            ml = currentMl;
1008            *offsetPtr = curr
1009                .wrapping_sub(matchIndex.wrapping_add(ddsIndexDelta))
1010                .wrapping_add(ZSTD_REP_NUM as u32) as size_t;
1011            if ip.add(currentMl) == iLimit {
1012                return ml;
1013            }
1014        }
1015        ddsAttempt = ddsAttempt.wrapping_add(1);
1016    }
1017    let chainPackedPointer_0 =
1018        *((*dms).hashTable).add(ddsIdx.wrapping_add(bucketSize as size_t).wrapping_sub(1));
1019    let mut chainIndex_0 = chainPackedPointer_0 >> 8;
1020    let chainLength = chainPackedPointer_0 & 0xff as core::ffi::c_int as u32;
1021    let chainAttempts = nbAttempts.wrapping_sub(ddsAttempt);
1022    let chainLimit = if chainAttempts > chainLength {
1023        chainLength
1024    } else {
1025        chainAttempts
1026    };
1027    let mut chainAttempt: u32 = 0;
1028    chainAttempt = 0;
1029    while chainAttempt < chainLimit {
1030        chainAttempt = chainAttempt.wrapping_add(1);
1031    }
1032    chainAttempt = 0;
1033    while chainAttempt < chainLimit {
1034        let mut currentMl_0 = 0;
1035        let mut match_1 = core::ptr::null::<u8>();
1036        matchIndex = *((*dms).chainTable).offset(chainIndex_0 as isize);
1037        match_1 = ddsBase.offset(matchIndex as isize);
1038        if MEM_read32(match_1 as *const core::ffi::c_void)
1039            == MEM_read32(ip as *const core::ffi::c_void)
1040        {
1041            currentMl_0 = (ZSTD_count_2segments(
1042                ip.offset(4),
1043                match_1.offset(4),
1044                iLimit,
1045                ddsEnd,
1046                prefixStart,
1047            ))
1048            .wrapping_add(4);
1049        }
1050        if currentMl_0 > ml {
1051            ml = currentMl_0;
1052            *offsetPtr = curr
1053                .wrapping_sub(matchIndex.wrapping_add(ddsIndexDelta))
1054                .wrapping_add(ZSTD_REP_NUM as u32) as size_t;
1055            if ip.add(currentMl_0) == iLimit {
1056                break;
1057            }
1058        }
1059        chainAttempt = chainAttempt.wrapping_add(1);
1060        chainIndex_0 = chainIndex_0.wrapping_add(1);
1061    }
1062    ml
1063}
1064#[inline(always)]
1065unsafe fn ZSTD_insertAndFindFirstIndex_internal(
1066    ms: *mut ZSTD_MatchState_t,
1067    cParams: *const ZSTD_compressionParameters,
1068    ip: *const u8,
1069    mls: u32,
1070    lazySkipping: u32,
1071) -> u32 {
1072    let hashTable = (*ms).hashTable;
1073    let hashLog = (*cParams).hashLog;
1074    let chainTable = (*ms).chainTable;
1075    let chainMask = (((1) << (*cParams).chainLog) - 1) as u32;
1076    let base = (*ms).window.base;
1077    let target = ip.offset_from(base) as core::ffi::c_long as u32;
1078    let mut idx = (*ms).nextToUpdate;
1079    while idx < target {
1080        let h = ZSTD_hashPtr(
1081            base.offset(idx as isize) as *const core::ffi::c_void,
1082            hashLog,
1083            mls,
1084        );
1085        *chainTable.offset((idx & chainMask) as isize) = *hashTable.add(h);
1086        *hashTable.add(h) = idx;
1087        idx = idx.wrapping_add(1);
1088        if lazySkipping != 0 {
1089            break;
1090        }
1091    }
1092    (*ms).nextToUpdate = target;
1093    *hashTable.add(ZSTD_hashPtr(ip as *const core::ffi::c_void, hashLog, mls))
1094}
1095pub unsafe fn ZSTD_insertAndFindFirstIndex(ms: *mut ZSTD_MatchState_t, ip: *const u8) -> u32 {
1096    let cParams: *const ZSTD_compressionParameters = &mut (*ms).cParams;
1097    ZSTD_insertAndFindFirstIndex_internal(ms, cParams, ip, (*ms).cParams.minMatch, 0)
1098}
1099#[inline(always)]
1100unsafe fn ZSTD_HcFindBestMatch(
1101    ms: *mut ZSTD_MatchState_t,
1102    ip: *const u8,
1103    iLimit: *const u8,
1104    offsetPtr: *mut size_t,
1105    mls: u32,
1106    dictMode: ZSTD_dictMode_e,
1107) -> size_t {
1108    let cParams: *const ZSTD_compressionParameters = &mut (*ms).cParams;
1109    let chainTable = (*ms).chainTable;
1110    let chainSize = ((1) << (*cParams).chainLog) as u32;
1111    let chainMask = chainSize.wrapping_sub(1);
1112    let base = (*ms).window.base;
1113    let dictBase = (*ms).window.dictBase;
1114    let dictLimit = (*ms).window.dictLimit;
1115    let prefixStart = base.offset(dictLimit as isize);
1116    let dictEnd = dictBase.offset(dictLimit as isize);
1117    let curr = ip.offset_from(base) as core::ffi::c_long as u32;
1118    let maxDistance = (1) << (*cParams).windowLog;
1119    let lowestValid = (*ms).window.lowLimit;
1120    let withinMaxDistance = if curr.wrapping_sub(lowestValid) > maxDistance {
1121        curr.wrapping_sub(maxDistance)
1122    } else {
1123        lowestValid
1124    };
1125    let isDictionary = ((*ms).loadedDictEnd != 0) as core::ffi::c_int as u32;
1126    let lowLimit = if isDictionary != 0 {
1127        lowestValid
1128    } else {
1129        withinMaxDistance
1130    };
1131    let minChain = if curr > chainSize {
1132        curr.wrapping_sub(chainSize)
1133    } else {
1134        0
1135    };
1136    let mut nbAttempts = (1 as core::ffi::c_uint) << (*cParams).searchLog;
1137    let mut ml = (4 - 1) as size_t;
1138    let dms = (*ms).dictMatchState;
1139    let ddsHashLog = if dictMode as core::ffi::c_uint
1140        == ZSTD_dedicatedDictSearch as core::ffi::c_int as core::ffi::c_uint
1141    {
1142        ((*dms).cParams.hashLog).wrapping_sub(ZSTD_LAZY_DDSS_BUCKET_LOG as core::ffi::c_uint)
1143    } else {
1144        0
1145    };
1146    let ddsIdx = if dictMode as core::ffi::c_uint
1147        == ZSTD_dedicatedDictSearch as core::ffi::c_int as core::ffi::c_uint
1148    {
1149        ZSTD_hashPtr(ip as *const core::ffi::c_void, ddsHashLog, mls) << ZSTD_LAZY_DDSS_BUCKET_LOG
1150    } else {
1151        0
1152    };
1153    let mut matchIndex: u32 = 0;
1154    if dictMode as core::ffi::c_uint
1155        == ZSTD_dedicatedDictSearch as core::ffi::c_int as core::ffi::c_uint
1156    {
1157        let entry: *const u32 = &mut *((*dms).hashTable).add(ddsIdx) as *mut u32;
1158    }
1159    matchIndex =
1160        ZSTD_insertAndFindFirstIndex_internal(ms, cParams, ip, mls, (*ms).lazySkipping as u32);
1161    while (matchIndex >= lowLimit) as core::ffi::c_int & (nbAttempts > 0) as core::ffi::c_int != 0 {
1162        let mut currentMl = 0;
1163        if dictMode as core::ffi::c_uint != ZSTD_extDict as core::ffi::c_int as core::ffi::c_uint
1164            || matchIndex >= dictLimit
1165        {
1166            let match_0 = base.offset(matchIndex as isize);
1167            if MEM_read32(match_0.add(ml).offset(-(3)) as *const core::ffi::c_void)
1168                == MEM_read32(ip.add(ml).offset(-(3)) as *const core::ffi::c_void)
1169            {
1170                currentMl = ZSTD_count(ip, match_0, iLimit);
1171            }
1172        } else {
1173            let match_1 = dictBase.offset(matchIndex as isize);
1174            if MEM_read32(match_1 as *const core::ffi::c_void)
1175                == MEM_read32(ip as *const core::ffi::c_void)
1176            {
1177                currentMl = (ZSTD_count_2segments(
1178                    ip.offset(4),
1179                    match_1.offset(4),
1180                    iLimit,
1181                    dictEnd,
1182                    prefixStart,
1183                ))
1184                .wrapping_add(4);
1185            }
1186        }
1187        if currentMl > ml {
1188            ml = currentMl;
1189            *offsetPtr = curr
1190                .wrapping_sub(matchIndex)
1191                .wrapping_add(ZSTD_REP_NUM as u32) as size_t;
1192            if ip.add(currentMl) == iLimit {
1193                break;
1194            }
1195        }
1196        if matchIndex <= minChain {
1197            break;
1198        }
1199        matchIndex = *chainTable.offset((matchIndex & chainMask) as isize);
1200        nbAttempts = nbAttempts.wrapping_sub(1);
1201    }
1202    if dictMode as core::ffi::c_uint
1203        == ZSTD_dedicatedDictSearch as core::ffi::c_int as core::ffi::c_uint
1204    {
1205        ml = ZSTD_dedicatedDictSearch_lazy_search(
1206            offsetPtr,
1207            ml,
1208            nbAttempts,
1209            dms,
1210            ip,
1211            iLimit,
1212            prefixStart,
1213            curr,
1214            dictLimit,
1215            ddsIdx,
1216        );
1217    } else if dictMode as core::ffi::c_uint
1218        == ZSTD_dictMatchState as core::ffi::c_int as core::ffi::c_uint
1219    {
1220        let dmsChainTable: *const u32 = (*dms).chainTable;
1221        let dmsChainSize = ((1) << (*dms).cParams.chainLog) as u32;
1222        let dmsChainMask = dmsChainSize.wrapping_sub(1);
1223        let dmsLowestIndex = (*dms).window.dictLimit;
1224        let dmsBase = (*dms).window.base;
1225        let dmsEnd = (*dms).window.nextSrc;
1226        let dmsSize = dmsEnd.offset_from(dmsBase) as core::ffi::c_long as u32;
1227        let dmsIndexDelta = dictLimit.wrapping_sub(dmsSize);
1228        let dmsMinChain = if dmsSize > dmsChainSize {
1229            dmsSize.wrapping_sub(dmsChainSize)
1230        } else {
1231            0
1232        };
1233        matchIndex = *((*dms).hashTable).add(ZSTD_hashPtr(
1234            ip as *const core::ffi::c_void,
1235            (*dms).cParams.hashLog,
1236            mls,
1237        ));
1238        while (matchIndex >= dmsLowestIndex) as core::ffi::c_int
1239            & (nbAttempts > 0) as core::ffi::c_int
1240            != 0
1241        {
1242            let mut currentMl_0 = 0;
1243            let match_2 = dmsBase.offset(matchIndex as isize);
1244            if MEM_read32(match_2 as *const core::ffi::c_void)
1245                == MEM_read32(ip as *const core::ffi::c_void)
1246            {
1247                currentMl_0 = (ZSTD_count_2segments(
1248                    ip.offset(4),
1249                    match_2.offset(4),
1250                    iLimit,
1251                    dmsEnd,
1252                    prefixStart,
1253                ))
1254                .wrapping_add(4);
1255            }
1256            if currentMl_0 > ml {
1257                ml = currentMl_0;
1258                *offsetPtr = curr
1259                    .wrapping_sub(matchIndex.wrapping_add(dmsIndexDelta))
1260                    .wrapping_add(ZSTD_REP_NUM as u32) as size_t;
1261                if ip.add(currentMl_0) == iLimit {
1262                    break;
1263                }
1264            }
1265            if matchIndex <= dmsMinChain {
1266                break;
1267            }
1268            matchIndex = *dmsChainTable.offset((matchIndex & dmsChainMask) as isize);
1269            nbAttempts = nbAttempts.wrapping_sub(1);
1270        }
1271    }
1272    ml
1273}
1274pub const ZSTD_ROW_HASH_TAG_MASK: core::ffi::c_uint =
1275    ((1 as core::ffi::c_uint) << ZSTD_ROW_HASH_TAG_BITS).wrapping_sub(1);
1276pub const ZSTD_ROW_HASH_CACHE_MASK: core::ffi::c_int = ZSTD_ROW_HASH_CACHE_SIZE - 1;
1277#[inline]
1278unsafe fn ZSTD_VecMask_next(val: ZSTD_VecMask) -> u32 {
1279    ZSTD_countTrailingZeros64(val)
1280}
1281#[inline(always)]
1282unsafe fn ZSTD_row_nextIndex(tagRow: *mut u8, rowMask: u32) -> u32 {
1283    let mut next = (*tagRow as core::ffi::c_int - 1) as u32 & rowMask;
1284    next = next.wrapping_add(if next == 0 { rowMask } else { 0 });
1285    *tagRow = next as u8;
1286    next
1287}
1288#[inline(always)]
1289unsafe fn ZSTD_row_prefetch(hashTable: *const u32, tagTable: *const u8, relRow: u32, rowLog: u32) {
1290    rowLog >= 5;
1291    rowLog == 6;
1292}
1293#[inline(always)]
1294unsafe fn ZSTD_row_fillHashCache(
1295    ms: *mut ZSTD_MatchState_t,
1296    base: *const u8,
1297    rowLog: u32,
1298    mls: u32,
1299    mut idx: u32,
1300    iLimit: *const u8,
1301) {
1302    let hashTable: *const u32 = (*ms).hashTable;
1303    let tagTable: *const u8 = (*ms).tagTable;
1304    let hashLog = (*ms).rowHashLog;
1305    let maxElemsToPrefetch = if base.offset(idx as isize) > iLimit {
1306        0
1307    } else {
1308        (iLimit.offset_from(base.offset(idx as isize)) as core::ffi::c_long + 1) as u32
1309    };
1310    let lim = idx.wrapping_add(if (8) < maxElemsToPrefetch {
1311        8
1312    } else {
1313        maxElemsToPrefetch
1314    });
1315    while idx < lim {
1316        let hash = ZSTD_hashPtrSalted(
1317            base.offset(idx as isize) as *const core::ffi::c_void,
1318            hashLog.wrapping_add(ZSTD_ROW_HASH_TAG_BITS as u32),
1319            mls,
1320            (*ms).hashSalt,
1321        ) as u32;
1322        let row = hash >> ZSTD_ROW_HASH_TAG_BITS << rowLog;
1323        ZSTD_row_prefetch(hashTable, tagTable, row, rowLog);
1324        *((*ms).hashCache)
1325            .as_mut_ptr()
1326            .offset((idx & ZSTD_ROW_HASH_CACHE_MASK as u32) as isize) = hash;
1327        idx = idx.wrapping_add(1);
1328    }
1329}
1330#[inline(always)]
1331unsafe fn ZSTD_row_nextCachedHash(
1332    cache: *mut u32,
1333    hashTable: *const u32,
1334    tagTable: *const u8,
1335    base: *const u8,
1336    idx: u32,
1337    hashLog: u32,
1338    rowLog: u32,
1339    mls: u32,
1340    hashSalt: u64,
1341) -> u32 {
1342    let newHash = ZSTD_hashPtrSalted(
1343        base.offset(idx as isize)
1344            .offset(ZSTD_ROW_HASH_CACHE_SIZE as isize) as *const core::ffi::c_void,
1345        hashLog.wrapping_add(ZSTD_ROW_HASH_TAG_BITS as u32),
1346        mls,
1347        hashSalt,
1348    ) as u32;
1349    let row = newHash >> ZSTD_ROW_HASH_TAG_BITS << rowLog;
1350    ZSTD_row_prefetch(hashTable, tagTable, row, rowLog);
1351    let hash = *cache.offset((idx & ZSTD_ROW_HASH_CACHE_MASK as u32) as isize);
1352    *cache.offset((idx & ZSTD_ROW_HASH_CACHE_MASK as u32) as isize) = newHash;
1353    hash
1354}
1355#[inline(always)]
1356unsafe fn ZSTD_row_update_internalImpl(
1357    ms: *mut ZSTD_MatchState_t,
1358    mut updateStartIdx: u32,
1359    updateEndIdx: u32,
1360    mls: u32,
1361    rowLog: u32,
1362    rowMask: u32,
1363    useCache: u32,
1364) {
1365    let hashTable = (*ms).hashTable;
1366    let tagTable = (*ms).tagTable;
1367    let hashLog = (*ms).rowHashLog;
1368    let base = (*ms).window.base;
1369    while updateStartIdx < updateEndIdx {
1370        let hash = if useCache != 0 {
1371            ZSTD_row_nextCachedHash(
1372                ((*ms).hashCache).as_mut_ptr(),
1373                hashTable,
1374                tagTable,
1375                base,
1376                updateStartIdx,
1377                hashLog,
1378                rowLog,
1379                mls,
1380                (*ms).hashSalt,
1381            )
1382        } else {
1383            ZSTD_hashPtrSalted(
1384                base.offset(updateStartIdx as isize) as *const core::ffi::c_void,
1385                hashLog.wrapping_add(ZSTD_ROW_HASH_TAG_BITS as u32),
1386                mls,
1387                (*ms).hashSalt,
1388            ) as u32
1389        };
1390        let relRow = hash >> ZSTD_ROW_HASH_TAG_BITS << rowLog;
1391        let row = hashTable.offset(relRow as isize);
1392        let tagRow = tagTable.offset(relRow as isize);
1393        let pos = ZSTD_row_nextIndex(tagRow, rowMask);
1394        *tagRow.offset(pos as isize) = (hash & ZSTD_ROW_HASH_TAG_MASK) as u8;
1395        *row.offset(pos as isize) = updateStartIdx;
1396        updateStartIdx = updateStartIdx.wrapping_add(1);
1397    }
1398}
1399#[inline(always)]
1400unsafe fn ZSTD_row_update_internal(
1401    ms: *mut ZSTD_MatchState_t,
1402    ip: *const u8,
1403    mls: u32,
1404    rowLog: u32,
1405    rowMask: u32,
1406    useCache: u32,
1407) {
1408    let mut idx = (*ms).nextToUpdate;
1409    let base = (*ms).window.base;
1410    let target = ip.offset_from(base) as core::ffi::c_long as u32;
1411    let kSkipThreshold = 384;
1412    let kMaxMatchStartPositionsToUpdate = 96;
1413    let kMaxMatchEndPositionsToUpdate = 32;
1414    if useCache != 0
1415        && (target.wrapping_sub(idx) > kSkipThreshold) as core::ffi::c_int as core::ffi::c_long != 0
1416    {
1417        let bound = idx.wrapping_add(kMaxMatchStartPositionsToUpdate);
1418        ZSTD_row_update_internalImpl(ms, idx, bound, mls, rowLog, rowMask, useCache);
1419        idx = target.wrapping_sub(kMaxMatchEndPositionsToUpdate);
1420        ZSTD_row_fillHashCache(ms, base, rowLog, mls, idx, ip.offset(1));
1421    }
1422    ZSTD_row_update_internalImpl(ms, idx, target, mls, rowLog, rowMask, useCache);
1423    (*ms).nextToUpdate = target;
1424}
1425pub unsafe fn ZSTD_row_update(ms: *mut ZSTD_MatchState_t, ip: *const u8) {
1426    let rowLog = if 4
1427        > (if (*ms).cParams.searchLog < 6 {
1428            (*ms).cParams.searchLog
1429        } else {
1430            6
1431        }) {
1432        4
1433    } else if (*ms).cParams.searchLog < 6 {
1434        (*ms).cParams.searchLog
1435    } else {
1436        6
1437    };
1438    let rowMask = ((1 as core::ffi::c_uint) << rowLog).wrapping_sub(1);
1439    let mls = if (*ms).cParams.minMatch < 6 as core::ffi::c_uint {
1440        (*ms).cParams.minMatch
1441    } else {
1442        6
1443    };
1444    ZSTD_row_update_internal(ms, ip, mls, rowLog, rowMask, 0);
1445}
1446#[inline(always)]
1447unsafe fn ZSTD_row_matchMaskGroupWidth(rowEntries: u32) -> u32 {
1448    1
1449}
1450#[inline(always)]
1451#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
1452unsafe fn ZSTD_row_getSSEMask(
1453    nbChunks: core::ffi::c_int,
1454    src: *const u8,
1455    tag: u8,
1456    head: u32,
1457) -> ZSTD_VecMask {
1458    #[cfg(target_arch = "x86")]
1459    use core::arch::x86::{
1460        __m128i, _mm_cmpeq_epi8, _mm_loadu_si128, _mm_movemask_epi8, _mm_set1_epi8,
1461    };
1462    #[cfg(target_arch = "x86_64")]
1463    use core::arch::x86_64::{
1464        __m128i, _mm_cmpeq_epi8, _mm_loadu_si128, _mm_movemask_epi8, _mm_set1_epi8,
1465    };
1466
1467    let comparisonMask = _mm_set1_epi8(tag as core::ffi::c_char);
1468    let mut matches: [core::ffi::c_int; 4] = [0; 4];
1469    let mut i: core::ffi::c_int = 0;
1470    i = 0;
1471    while i < nbChunks {
1472        let chunk = _mm_loadu_si128(
1473            src.offset((16 * i) as isize) as *const core::ffi::c_void as *const __m128i
1474        );
1475        let equalMask = _mm_cmpeq_epi8(chunk, comparisonMask);
1476        *matches.as_mut_ptr().offset(i as isize) = _mm_movemask_epi8(equalMask);
1477        i += 1;
1478    }
1479    if nbChunks == 1 {
1480        return ZSTD_rotateRight_U16(*matches.as_mut_ptr().offset(0) as u16, head) as ZSTD_VecMask;
1481    }
1482    if nbChunks == 2 {
1483        return ZSTD_rotateRight_U32(
1484            (*matches.as_mut_ptr().offset(1) as u32) << 16 | *matches.as_mut_ptr().offset(0) as u32,
1485            head,
1486        ) as ZSTD_VecMask;
1487    }
1488    ZSTD_rotateRight_U64(
1489        (*matches.as_mut_ptr().offset(3) as u64) << 48
1490            | (*matches.as_mut_ptr().offset(2) as u64) << 32
1491            | (*matches.as_mut_ptr().offset(1) as u64) << 16
1492            | *matches.as_mut_ptr().offset(0) as u64,
1493        head,
1494    )
1495}
1496#[inline(always)]
1497unsafe fn ZSTD_row_getMatchMask(
1498    tagRow: *const u8,
1499    tag: u8,
1500    headGrouped: u32,
1501    rowEntries: u32,
1502) -> ZSTD_VecMask {
1503    let src = tagRow;
1504
1505    #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
1506    if true {
1507        return ZSTD_row_getSSEMask((rowEntries / 16) as core::ffi::c_int, src, tag, headGrouped);
1508    }
1509
1510    // FIXME: Evaluate if the custom SIMD implementation is worth it on x86, and if so also add an
1511    // aarch64 implementation.
1512
1513    // Fallback using Simd Within A Register (SWAR).
1514
1515    let chunkSize = size_of::<usize>();
1516    let shiftAmount = (chunkSize * 8) - chunkSize;
1517    let xFF = usize::MAX;
1518    let x01 = xFF / 0xFF;
1519    let x80 = x01 << 7;
1520    let splatChar = usize::from(tag) * x01;
1521
1522    let mut matches: ZSTD_VecMask = 0;
1523    let mut i = rowEntries as isize - chunkSize as isize;
1524    assert!((size_of::<usize>() == 4) || (size_of::<usize>() == 8));
1525
1526    if cfg!(target_endian = "little") {
1527        let extractMagic = (xFF / 0x7F) >> chunkSize;
1528
1529        loop {
1530            let mut chunk = src.offset(i).cast::<usize>().read_unaligned();
1531            chunk ^= splatChar;
1532            chunk = (((chunk | x80) - x01) | chunk) & x80;
1533            matches <<= chunkSize;
1534            matches |= ((chunk * extractMagic) >> shiftAmount) as ZSTD_VecMask;
1535            i -= chunkSize as isize;
1536
1537            if i < 0 {
1538                break;
1539            }
1540        }
1541    } else {
1542        // big endian: reverse bits during extraction.
1543        let msb = xFF ^ (xFF >> 1);
1544        let extractMagic = (msb / 0x1FF) | msb;
1545
1546        loop {
1547            let mut chunk = src.offset(i).cast::<usize>().read_unaligned();
1548            chunk ^= splatChar;
1549            chunk = (((chunk | x80) - x01) | chunk) & x80;
1550            matches <<= chunkSize;
1551            matches |= (((chunk >> 7) * extractMagic) >> shiftAmount) as ZSTD_VecMask;
1552            i -= chunkSize as isize;
1553
1554            if i < 0 {
1555                break;
1556            }
1557        }
1558    }
1559
1560    matches = !matches;
1561    match rowEntries {
1562        16 => (matches as u16).rotate_right(headGrouped) as ZSTD_VecMask,
1563        32 => (matches as u32).rotate_right(headGrouped) as ZSTD_VecMask,
1564        64 => (matches as u64).rotate_right(headGrouped) as ZSTD_VecMask,
1565        _ => unreachable!(),
1566    }
1567}
1568
1569#[inline(always)]
1570unsafe fn ZSTD_RowFindBestMatch(
1571    ms: *mut ZSTD_MatchState_t,
1572    ip: *const u8,
1573    iLimit: *const u8,
1574    offsetPtr: *mut size_t,
1575    mls: u32,
1576    dictMode: ZSTD_dictMode_e,
1577    rowLog: u32,
1578) -> size_t {
1579    let hashTable = (*ms).hashTable;
1580    let tagTable = (*ms).tagTable;
1581    let hashCache = ((*ms).hashCache).as_mut_ptr();
1582    let hashLog = (*ms).rowHashLog;
1583    let cParams: *const ZSTD_compressionParameters = &mut (*ms).cParams;
1584    let base = (*ms).window.base;
1585    let dictBase = (*ms).window.dictBase;
1586    let dictLimit = (*ms).window.dictLimit;
1587    let prefixStart = base.offset(dictLimit as isize);
1588    let dictEnd = dictBase.offset(dictLimit as isize);
1589    let curr = ip.offset_from(base) as core::ffi::c_long as u32;
1590    let maxDistance = (1) << (*cParams).windowLog;
1591    let lowestValid = (*ms).window.lowLimit;
1592    let withinMaxDistance = if curr.wrapping_sub(lowestValid) > maxDistance {
1593        curr.wrapping_sub(maxDistance)
1594    } else {
1595        lowestValid
1596    };
1597    let isDictionary = ((*ms).loadedDictEnd != 0) as core::ffi::c_int as u32;
1598    let lowLimit = if isDictionary != 0 {
1599        lowestValid
1600    } else {
1601        withinMaxDistance
1602    };
1603    let rowEntries = (1 as core::ffi::c_uint) << rowLog;
1604    let rowMask = rowEntries.wrapping_sub(1);
1605    let cappedSearchLog = if (*cParams).searchLog < rowLog {
1606        (*cParams).searchLog
1607    } else {
1608        rowLog
1609    };
1610    let groupWidth = ZSTD_row_matchMaskGroupWidth(rowEntries);
1611    let hashSalt = (*ms).hashSalt;
1612    let mut nbAttempts = (1 as core::ffi::c_uint) << cappedSearchLog;
1613    let mut ml = (4 - 1) as size_t;
1614    let mut hash: u32 = 0;
1615    let dms = (*ms).dictMatchState;
1616    let mut ddsIdx = 0;
1617    let mut ddsExtraAttempts = 0;
1618    let mut dmsTag = 0;
1619    let mut dmsRow = core::ptr::null_mut();
1620    let mut dmsTagRow = core::ptr::null_mut();
1621    if dictMode as core::ffi::c_uint
1622        == ZSTD_dedicatedDictSearch as core::ffi::c_int as core::ffi::c_uint
1623    {
1624        let ddsHashLog =
1625            ((*dms).cParams.hashLog).wrapping_sub(ZSTD_LAZY_DDSS_BUCKET_LOG as core::ffi::c_uint);
1626        ddsIdx = ZSTD_hashPtr(ip as *const core::ffi::c_void, ddsHashLog, mls)
1627            << ZSTD_LAZY_DDSS_BUCKET_LOG;
1628        ((*dms).hashTable).add(ddsIdx);
1629        ddsExtraAttempts = if (*cParams).searchLog > rowLog {
1630            (1) << ((*cParams).searchLog).wrapping_sub(rowLog)
1631        } else {
1632            0
1633        };
1634    }
1635    if dictMode as core::ffi::c_uint == ZSTD_dictMatchState as core::ffi::c_int as core::ffi::c_uint
1636    {
1637        let dmsHashTable = (*dms).hashTable;
1638        let dmsTagTable = (*dms).tagTable;
1639        let dmsHash = ZSTD_hashPtr(
1640            ip as *const core::ffi::c_void,
1641            ((*dms).rowHashLog).wrapping_add(ZSTD_ROW_HASH_TAG_BITS as u32),
1642            mls,
1643        ) as u32;
1644        let dmsRelRow = dmsHash >> ZSTD_ROW_HASH_TAG_BITS << rowLog;
1645        dmsTag = dmsHash & ZSTD_ROW_HASH_TAG_MASK;
1646        dmsTagRow = dmsTagTable.offset(dmsRelRow as isize);
1647        dmsRow = dmsHashTable.offset(dmsRelRow as isize);
1648        ZSTD_row_prefetch(dmsHashTable, dmsTagTable, dmsRelRow, rowLog);
1649    }
1650    if (*ms).lazySkipping == 0 {
1651        ZSTD_row_update_internal(ms, ip, mls, rowLog, rowMask, 1);
1652        hash = ZSTD_row_nextCachedHash(
1653            hashCache, hashTable, tagTable, base, curr, hashLog, rowLog, mls, hashSalt,
1654        );
1655    } else {
1656        hash = ZSTD_hashPtrSalted(
1657            ip as *const core::ffi::c_void,
1658            hashLog.wrapping_add(ZSTD_ROW_HASH_TAG_BITS as u32),
1659            mls,
1660            hashSalt,
1661        ) as u32;
1662        (*ms).nextToUpdate = curr;
1663    }
1664    (*ms).hashSaltEntropy = ((*ms).hashSaltEntropy).wrapping_add(hash);
1665    let relRow = hash >> ZSTD_ROW_HASH_TAG_BITS << rowLog;
1666    let tag = hash & ZSTD_ROW_HASH_TAG_MASK;
1667    let row = hashTable.offset(relRow as isize);
1668    let tagRow = tagTable.offset(relRow as isize);
1669    let headGrouped = (*tagRow as u32 & rowMask) * groupWidth;
1670    let mut matchBuffer: [u32; 64] = [0; 64];
1671    let mut numMatches = 0 as size_t;
1672    let mut currMatch = 0;
1673    let mut matches = ZSTD_row_getMatchMask(tagRow, tag as u8, headGrouped, rowEntries);
1674    while matches > 0 && nbAttempts > 0 {
1675        let matchPos =
1676            (headGrouped.wrapping_add(ZSTD_VecMask_next(matches)) / groupWidth) & rowMask;
1677        let matchIndex = *row.offset(matchPos as isize);
1678        if matchPos != 0 {
1679            if matchIndex < lowLimit {
1680                break;
1681            }
1682            if dictMode as core::ffi::c_uint
1683                == ZSTD_extDict as core::ffi::c_int as core::ffi::c_uint
1684            {
1685                matchIndex >= dictLimit;
1686            }
1687            let fresh3 = numMatches;
1688            numMatches = numMatches.wrapping_add(1);
1689            *matchBuffer.as_mut_ptr().add(fresh3) = matchIndex;
1690            nbAttempts = nbAttempts.wrapping_sub(1);
1691        }
1692        matches &= matches.wrapping_sub(1);
1693    }
1694    let pos = ZSTD_row_nextIndex(tagRow, rowMask);
1695    *tagRow.offset(pos as isize) = tag as u8;
1696    let fresh4 = (*ms).nextToUpdate;
1697    (*ms).nextToUpdate = ((*ms).nextToUpdate).wrapping_add(1);
1698    *row.offset(pos as isize) = fresh4;
1699    while currMatch < numMatches {
1700        let matchIndex_0 = *matchBuffer.as_mut_ptr().add(currMatch);
1701        let mut currentMl = 0;
1702        if dictMode as core::ffi::c_uint != ZSTD_extDict as core::ffi::c_int as core::ffi::c_uint
1703            || matchIndex_0 >= dictLimit
1704        {
1705            let match_0 = base.offset(matchIndex_0 as isize);
1706            if MEM_read32(match_0.add(ml).offset(-(3)) as *const core::ffi::c_void)
1707                == MEM_read32(ip.add(ml).offset(-(3)) as *const core::ffi::c_void)
1708            {
1709                currentMl = ZSTD_count(ip, match_0, iLimit);
1710            }
1711        } else {
1712            let match_1 = dictBase.offset(matchIndex_0 as isize);
1713            if MEM_read32(match_1 as *const core::ffi::c_void)
1714                == MEM_read32(ip as *const core::ffi::c_void)
1715            {
1716                currentMl = (ZSTD_count_2segments(
1717                    ip.offset(4),
1718                    match_1.offset(4),
1719                    iLimit,
1720                    dictEnd,
1721                    prefixStart,
1722                ))
1723                .wrapping_add(4);
1724            }
1725        }
1726        if currentMl > ml {
1727            ml = currentMl;
1728            *offsetPtr = curr
1729                .wrapping_sub(matchIndex_0)
1730                .wrapping_add(ZSTD_REP_NUM as u32) as size_t;
1731            if ip.add(currentMl) == iLimit {
1732                break;
1733            }
1734        }
1735        currMatch = currMatch.wrapping_add(1);
1736    }
1737    if dictMode as core::ffi::c_uint
1738        == ZSTD_dedicatedDictSearch as core::ffi::c_int as core::ffi::c_uint
1739    {
1740        ml = ZSTD_dedicatedDictSearch_lazy_search(
1741            offsetPtr,
1742            ml,
1743            nbAttempts.wrapping_add(ddsExtraAttempts),
1744            dms,
1745            ip,
1746            iLimit,
1747            prefixStart,
1748            curr,
1749            dictLimit,
1750            ddsIdx,
1751        );
1752    } else if dictMode as core::ffi::c_uint
1753        == ZSTD_dictMatchState as core::ffi::c_int as core::ffi::c_uint
1754    {
1755        let dmsLowestIndex = (*dms).window.dictLimit;
1756        let dmsBase = (*dms).window.base;
1757        let dmsEnd = (*dms).window.nextSrc;
1758        let dmsSize = dmsEnd.offset_from(dmsBase) as core::ffi::c_long as u32;
1759        let dmsIndexDelta = dictLimit.wrapping_sub(dmsSize);
1760        let headGrouped_0 = (*dmsTagRow as u32 & rowMask) * groupWidth;
1761        let mut matchBuffer_0: [u32; 64] = [0; 64];
1762        let mut numMatches_0 = 0 as size_t;
1763        let mut currMatch_0 = 0;
1764        let mut matches_0 =
1765            ZSTD_row_getMatchMask(dmsTagRow, dmsTag as u8, headGrouped_0, rowEntries);
1766        while matches_0 > 0 && nbAttempts > 0 {
1767            let matchPos_0 =
1768                (headGrouped_0.wrapping_add(ZSTD_VecMask_next(matches_0)) / groupWidth) & rowMask;
1769            let matchIndex_1 = *dmsRow.offset(matchPos_0 as isize);
1770            if matchPos_0 != 0 {
1771                if matchIndex_1 < dmsLowestIndex {
1772                    break;
1773                }
1774                let fresh5 = numMatches_0;
1775                numMatches_0 = numMatches_0.wrapping_add(1);
1776                *matchBuffer_0.as_mut_ptr().add(fresh5) = matchIndex_1;
1777                nbAttempts = nbAttempts.wrapping_sub(1);
1778            }
1779            matches_0 &= matches_0.wrapping_sub(1);
1780        }
1781        while currMatch_0 < numMatches_0 {
1782            let matchIndex_2 = *matchBuffer_0.as_mut_ptr().add(currMatch_0);
1783            let mut currentMl_0 = 0;
1784            let match_2 = dmsBase.offset(matchIndex_2 as isize);
1785            if MEM_read32(match_2 as *const core::ffi::c_void)
1786                == MEM_read32(ip as *const core::ffi::c_void)
1787            {
1788                currentMl_0 = (ZSTD_count_2segments(
1789                    ip.offset(4),
1790                    match_2.offset(4),
1791                    iLimit,
1792                    dmsEnd,
1793                    prefixStart,
1794                ))
1795                .wrapping_add(4);
1796            }
1797            if currentMl_0 > ml {
1798                ml = currentMl_0;
1799                *offsetPtr = curr
1800                    .wrapping_sub(matchIndex_2.wrapping_add(dmsIndexDelta))
1801                    .wrapping_add(ZSTD_REP_NUM as u32) as size_t;
1802                if ip.add(currentMl_0) == iLimit {
1803                    break;
1804                }
1805            }
1806            currMatch_0 = currMatch_0.wrapping_add(1);
1807        }
1808    }
1809    ml
1810}
1811#[inline(never)]
1812unsafe fn ZSTD_RowFindBestMatch_dictMatchState_6_6(
1813    ms: *mut ZSTD_MatchState_t,
1814    ip: *const u8,
1815    iLimit: *const u8,
1816    offsetPtr: *mut size_t,
1817) -> size_t {
1818    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_dictMatchState, 6)
1819}
1820#[inline(never)]
1821unsafe fn ZSTD_RowFindBestMatch_extDict_4_6(
1822    ms: *mut ZSTD_MatchState_t,
1823    ip: *const u8,
1824    iLimit: *const u8,
1825    offsetPtr: *mut size_t,
1826) -> size_t {
1827    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_extDict, 6)
1828}
1829#[inline(never)]
1830unsafe fn ZSTD_RowFindBestMatch_dictMatchState_4_4(
1831    ms: *mut ZSTD_MatchState_t,
1832    ip: *const u8,
1833    iLimit: *const u8,
1834    offsetPtr: *mut size_t,
1835) -> size_t {
1836    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_dictMatchState, 4)
1837}
1838#[inline(never)]
1839unsafe fn ZSTD_RowFindBestMatch_dedicatedDictSearch_6_6(
1840    ms: *mut ZSTD_MatchState_t,
1841    ip: *const u8,
1842    iLimit: *const u8,
1843    offsetPtr: *mut size_t,
1844) -> size_t {
1845    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_dedicatedDictSearch, 6)
1846}
1847#[inline(never)]
1848unsafe fn ZSTD_RowFindBestMatch_extDict_6_6(
1849    ms: *mut ZSTD_MatchState_t,
1850    ip: *const u8,
1851    iLimit: *const u8,
1852    offsetPtr: *mut size_t,
1853) -> size_t {
1854    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_extDict, 6)
1855}
1856#[inline(never)]
1857unsafe fn ZSTD_RowFindBestMatch_extDict_6_5(
1858    ms: *mut ZSTD_MatchState_t,
1859    ip: *const u8,
1860    iLimit: *const u8,
1861    offsetPtr: *mut size_t,
1862) -> size_t {
1863    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_extDict, 5)
1864}
1865#[inline(never)]
1866unsafe fn ZSTD_RowFindBestMatch_extDict_6_4(
1867    ms: *mut ZSTD_MatchState_t,
1868    ip: *const u8,
1869    iLimit: *const u8,
1870    offsetPtr: *mut size_t,
1871) -> size_t {
1872    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_extDict, 4)
1873}
1874#[inline(never)]
1875unsafe fn ZSTD_RowFindBestMatch_extDict_5_6(
1876    ms: *mut ZSTD_MatchState_t,
1877    ip: *const u8,
1878    iLimit: *const u8,
1879    offsetPtr: *mut size_t,
1880) -> size_t {
1881    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_extDict, 6)
1882}
1883#[inline(never)]
1884unsafe fn ZSTD_RowFindBestMatch_extDict_5_5(
1885    ms: *mut ZSTD_MatchState_t,
1886    ip: *const u8,
1887    iLimit: *const u8,
1888    offsetPtr: *mut size_t,
1889) -> size_t {
1890    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_extDict, 5)
1891}
1892#[inline(never)]
1893unsafe fn ZSTD_RowFindBestMatch_extDict_5_4(
1894    ms: *mut ZSTD_MatchState_t,
1895    ip: *const u8,
1896    iLimit: *const u8,
1897    offsetPtr: *mut size_t,
1898) -> size_t {
1899    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_extDict, 4)
1900}
1901#[inline(never)]
1902unsafe fn ZSTD_RowFindBestMatch_dictMatchState_4_5(
1903    ms: *mut ZSTD_MatchState_t,
1904    ip: *const u8,
1905    iLimit: *const u8,
1906    offsetPtr: *mut size_t,
1907) -> size_t {
1908    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_dictMatchState, 5)
1909}
1910#[inline(never)]
1911unsafe fn ZSTD_RowFindBestMatch_extDict_4_5(
1912    ms: *mut ZSTD_MatchState_t,
1913    ip: *const u8,
1914    iLimit: *const u8,
1915    offsetPtr: *mut size_t,
1916) -> size_t {
1917    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_extDict, 5)
1918}
1919#[inline(never)]
1920unsafe fn ZSTD_RowFindBestMatch_extDict_4_4(
1921    ms: *mut ZSTD_MatchState_t,
1922    ip: *const u8,
1923    iLimit: *const u8,
1924    offsetPtr: *mut size_t,
1925) -> size_t {
1926    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_extDict, 4)
1927}
1928#[inline(never)]
1929unsafe fn ZSTD_RowFindBestMatch_dedicatedDictSearch_6_5(
1930    ms: *mut ZSTD_MatchState_t,
1931    ip: *const u8,
1932    iLimit: *const u8,
1933    offsetPtr: *mut size_t,
1934) -> size_t {
1935    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_dedicatedDictSearch, 5)
1936}
1937#[inline(never)]
1938unsafe fn ZSTD_RowFindBestMatch_dedicatedDictSearch_6_4(
1939    ms: *mut ZSTD_MatchState_t,
1940    ip: *const u8,
1941    iLimit: *const u8,
1942    offsetPtr: *mut size_t,
1943) -> size_t {
1944    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_dedicatedDictSearch, 4)
1945}
1946#[inline(never)]
1947unsafe fn ZSTD_RowFindBestMatch_dedicatedDictSearch_5_6(
1948    ms: *mut ZSTD_MatchState_t,
1949    ip: *const u8,
1950    iLimit: *const u8,
1951    offsetPtr: *mut size_t,
1952) -> size_t {
1953    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_dedicatedDictSearch, 6)
1954}
1955#[inline(never)]
1956unsafe fn ZSTD_RowFindBestMatch_dedicatedDictSearch_5_5(
1957    ms: *mut ZSTD_MatchState_t,
1958    ip: *const u8,
1959    iLimit: *const u8,
1960    offsetPtr: *mut size_t,
1961) -> size_t {
1962    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_dedicatedDictSearch, 5)
1963}
1964#[inline(never)]
1965unsafe fn ZSTD_RowFindBestMatch_dedicatedDictSearch_5_4(
1966    ms: *mut ZSTD_MatchState_t,
1967    ip: *const u8,
1968    iLimit: *const u8,
1969    offsetPtr: *mut size_t,
1970) -> size_t {
1971    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_dedicatedDictSearch, 4)
1972}
1973#[inline(never)]
1974unsafe fn ZSTD_RowFindBestMatch_dedicatedDictSearch_4_6(
1975    ms: *mut ZSTD_MatchState_t,
1976    ip: *const u8,
1977    iLimit: *const u8,
1978    offsetPtr: *mut size_t,
1979) -> size_t {
1980    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_dedicatedDictSearch, 6)
1981}
1982#[inline(never)]
1983unsafe fn ZSTD_RowFindBestMatch_noDict_6_6(
1984    ms: *mut ZSTD_MatchState_t,
1985    ip: *const u8,
1986    iLimit: *const u8,
1987    offsetPtr: *mut size_t,
1988) -> size_t {
1989    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_noDict, 6)
1990}
1991#[inline(never)]
1992unsafe fn ZSTD_RowFindBestMatch_dedicatedDictSearch_4_5(
1993    ms: *mut ZSTD_MatchState_t,
1994    ip: *const u8,
1995    iLimit: *const u8,
1996    offsetPtr: *mut size_t,
1997) -> size_t {
1998    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_dedicatedDictSearch, 5)
1999}
2000#[inline(never)]
2001unsafe fn ZSTD_RowFindBestMatch_noDict_6_4(
2002    ms: *mut ZSTD_MatchState_t,
2003    ip: *const u8,
2004    iLimit: *const u8,
2005    offsetPtr: *mut size_t,
2006) -> size_t {
2007    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_noDict, 4)
2008}
2009#[inline(never)]
2010unsafe fn ZSTD_RowFindBestMatch_noDict_5_6(
2011    ms: *mut ZSTD_MatchState_t,
2012    ip: *const u8,
2013    iLimit: *const u8,
2014    offsetPtr: *mut size_t,
2015) -> size_t {
2016    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_noDict, 6)
2017}
2018#[inline(never)]
2019unsafe fn ZSTD_RowFindBestMatch_noDict_5_5(
2020    ms: *mut ZSTD_MatchState_t,
2021    ip: *const u8,
2022    iLimit: *const u8,
2023    offsetPtr: *mut size_t,
2024) -> size_t {
2025    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_noDict, 5)
2026}
2027#[inline(never)]
2028unsafe fn ZSTD_RowFindBestMatch_noDict_5_4(
2029    ms: *mut ZSTD_MatchState_t,
2030    ip: *const u8,
2031    iLimit: *const u8,
2032    offsetPtr: *mut size_t,
2033) -> size_t {
2034    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_noDict, 4)
2035}
2036#[inline(never)]
2037unsafe fn ZSTD_RowFindBestMatch_noDict_4_6(
2038    ms: *mut ZSTD_MatchState_t,
2039    ip: *const u8,
2040    iLimit: *const u8,
2041    offsetPtr: *mut size_t,
2042) -> size_t {
2043    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_noDict, 6)
2044}
2045#[inline(never)]
2046unsafe fn ZSTD_RowFindBestMatch_noDict_4_5(
2047    ms: *mut ZSTD_MatchState_t,
2048    ip: *const u8,
2049    iLimit: *const u8,
2050    offsetPtr: *mut size_t,
2051) -> size_t {
2052    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_noDict, 5)
2053}
2054#[inline(never)]
2055unsafe fn ZSTD_RowFindBestMatch_noDict_4_4(
2056    ms: *mut ZSTD_MatchState_t,
2057    ip: *const u8,
2058    iLimit: *const u8,
2059    offsetPtr: *mut size_t,
2060) -> size_t {
2061    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_noDict, 4)
2062}
2063#[inline(never)]
2064unsafe fn ZSTD_RowFindBestMatch_dedicatedDictSearch_4_4(
2065    ms: *mut ZSTD_MatchState_t,
2066    ip: *const u8,
2067    iLimit: *const u8,
2068    offsetPtr: *mut size_t,
2069) -> size_t {
2070    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_dedicatedDictSearch, 4)
2071}
2072#[inline(never)]
2073unsafe fn ZSTD_RowFindBestMatch_dictMatchState_4_6(
2074    ms: *mut ZSTD_MatchState_t,
2075    ip: *const u8,
2076    iLimit: *const u8,
2077    offsetPtr: *mut size_t,
2078) -> size_t {
2079    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_dictMatchState, 6)
2080}
2081#[inline(never)]
2082unsafe fn ZSTD_RowFindBestMatch_dictMatchState_6_5(
2083    ms: *mut ZSTD_MatchState_t,
2084    ip: *const u8,
2085    iLimit: *const u8,
2086    offsetPtr: *mut size_t,
2087) -> size_t {
2088    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_dictMatchState, 5)
2089}
2090#[inline(never)]
2091unsafe fn ZSTD_RowFindBestMatch_dictMatchState_6_4(
2092    ms: *mut ZSTD_MatchState_t,
2093    ip: *const u8,
2094    iLimit: *const u8,
2095    offsetPtr: *mut size_t,
2096) -> size_t {
2097    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_dictMatchState, 4)
2098}
2099#[inline(never)]
2100unsafe fn ZSTD_RowFindBestMatch_dictMatchState_5_6(
2101    ms: *mut ZSTD_MatchState_t,
2102    ip: *const u8,
2103    iLimit: *const u8,
2104    offsetPtr: *mut size_t,
2105) -> size_t {
2106    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_dictMatchState, 6)
2107}
2108#[inline(never)]
2109unsafe fn ZSTD_RowFindBestMatch_dictMatchState_5_5(
2110    ms: *mut ZSTD_MatchState_t,
2111    ip: *const u8,
2112    iLimit: *const u8,
2113    offsetPtr: *mut size_t,
2114) -> size_t {
2115    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_dictMatchState, 5)
2116}
2117#[inline(never)]
2118unsafe fn ZSTD_RowFindBestMatch_dictMatchState_5_4(
2119    ms: *mut ZSTD_MatchState_t,
2120    ip: *const u8,
2121    iLimit: *const u8,
2122    offsetPtr: *mut size_t,
2123) -> size_t {
2124    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_dictMatchState, 4)
2125}
2126#[inline(never)]
2127unsafe fn ZSTD_RowFindBestMatch_noDict_6_5(
2128    ms: *mut ZSTD_MatchState_t,
2129    ip: *const u8,
2130    iLimit: *const u8,
2131    offsetPtr: *mut size_t,
2132) -> size_t {
2133    ZSTD_RowFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_noDict, 5)
2134}
2135#[inline(never)]
2136unsafe fn ZSTD_BtFindBestMatch_noDict_6(
2137    ms: *mut ZSTD_MatchState_t,
2138    ip: *const u8,
2139    iLimit: *const u8,
2140    offBasePtr: *mut size_t,
2141) -> size_t {
2142    ZSTD_BtFindBestMatch(ms, ip, iLimit, offBasePtr, 6, ZSTD_noDict)
2143}
2144#[inline(never)]
2145unsafe fn ZSTD_BtFindBestMatch_dictMatchState_6(
2146    ms: *mut ZSTD_MatchState_t,
2147    ip: *const u8,
2148    iLimit: *const u8,
2149    offBasePtr: *mut size_t,
2150) -> size_t {
2151    ZSTD_BtFindBestMatch(ms, ip, iLimit, offBasePtr, 6, ZSTD_dictMatchState)
2152}
2153#[inline(never)]
2154unsafe fn ZSTD_BtFindBestMatch_noDict_5(
2155    ms: *mut ZSTD_MatchState_t,
2156    ip: *const u8,
2157    iLimit: *const u8,
2158    offBasePtr: *mut size_t,
2159) -> size_t {
2160    ZSTD_BtFindBestMatch(ms, ip, iLimit, offBasePtr, 5, ZSTD_noDict)
2161}
2162#[inline(never)]
2163unsafe fn ZSTD_BtFindBestMatch_dedicatedDictSearch_5(
2164    ms: *mut ZSTD_MatchState_t,
2165    ip: *const u8,
2166    iLimit: *const u8,
2167    offBasePtr: *mut size_t,
2168) -> size_t {
2169    ZSTD_BtFindBestMatch(ms, ip, iLimit, offBasePtr, 5, ZSTD_dedicatedDictSearch)
2170}
2171#[inline(never)]
2172unsafe fn ZSTD_BtFindBestMatch_dedicatedDictSearch_6(
2173    ms: *mut ZSTD_MatchState_t,
2174    ip: *const u8,
2175    iLimit: *const u8,
2176    offBasePtr: *mut size_t,
2177) -> size_t {
2178    ZSTD_BtFindBestMatch(ms, ip, iLimit, offBasePtr, 6, ZSTD_dedicatedDictSearch)
2179}
2180#[inline(never)]
2181unsafe fn ZSTD_BtFindBestMatch_dedicatedDictSearch_4(
2182    ms: *mut ZSTD_MatchState_t,
2183    ip: *const u8,
2184    iLimit: *const u8,
2185    offBasePtr: *mut size_t,
2186) -> size_t {
2187    ZSTD_BtFindBestMatch(ms, ip, iLimit, offBasePtr, 4, ZSTD_dedicatedDictSearch)
2188}
2189#[inline(never)]
2190unsafe fn ZSTD_BtFindBestMatch_extDict_4(
2191    ms: *mut ZSTD_MatchState_t,
2192    ip: *const u8,
2193    iLimit: *const u8,
2194    offBasePtr: *mut size_t,
2195) -> size_t {
2196    ZSTD_BtFindBestMatch(ms, ip, iLimit, offBasePtr, 4, ZSTD_extDict)
2197}
2198#[inline(never)]
2199unsafe fn ZSTD_BtFindBestMatch_dictMatchState_4(
2200    ms: *mut ZSTD_MatchState_t,
2201    ip: *const u8,
2202    iLimit: *const u8,
2203    offBasePtr: *mut size_t,
2204) -> size_t {
2205    ZSTD_BtFindBestMatch(ms, ip, iLimit, offBasePtr, 4, ZSTD_dictMatchState)
2206}
2207#[inline(never)]
2208unsafe fn ZSTD_BtFindBestMatch_extDict_6(
2209    ms: *mut ZSTD_MatchState_t,
2210    ip: *const u8,
2211    iLimit: *const u8,
2212    offBasePtr: *mut size_t,
2213) -> size_t {
2214    ZSTD_BtFindBestMatch(ms, ip, iLimit, offBasePtr, 6, ZSTD_extDict)
2215}
2216#[inline(never)]
2217unsafe fn ZSTD_BtFindBestMatch_noDict_4(
2218    ms: *mut ZSTD_MatchState_t,
2219    ip: *const u8,
2220    iLimit: *const u8,
2221    offBasePtr: *mut size_t,
2222) -> size_t {
2223    ZSTD_BtFindBestMatch(ms, ip, iLimit, offBasePtr, 4, ZSTD_noDict)
2224}
2225#[inline(never)]
2226unsafe fn ZSTD_BtFindBestMatch_extDict_5(
2227    ms: *mut ZSTD_MatchState_t,
2228    ip: *const u8,
2229    iLimit: *const u8,
2230    offBasePtr: *mut size_t,
2231) -> size_t {
2232    ZSTD_BtFindBestMatch(ms, ip, iLimit, offBasePtr, 5, ZSTD_extDict)
2233}
2234#[inline(never)]
2235unsafe fn ZSTD_BtFindBestMatch_dictMatchState_5(
2236    ms: *mut ZSTD_MatchState_t,
2237    ip: *const u8,
2238    iLimit: *const u8,
2239    offBasePtr: *mut size_t,
2240) -> size_t {
2241    ZSTD_BtFindBestMatch(ms, ip, iLimit, offBasePtr, 5, ZSTD_dictMatchState)
2242}
2243#[inline(never)]
2244unsafe fn ZSTD_HcFindBestMatch_noDict_6(
2245    ms: *mut ZSTD_MatchState_t,
2246    ip: *const u8,
2247    iLimit: *const u8,
2248    offsetPtr: *mut size_t,
2249) -> size_t {
2250    ZSTD_HcFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_noDict)
2251}
2252#[inline(never)]
2253unsafe fn ZSTD_HcFindBestMatch_dictMatchState_5(
2254    ms: *mut ZSTD_MatchState_t,
2255    ip: *const u8,
2256    iLimit: *const u8,
2257    offsetPtr: *mut size_t,
2258) -> size_t {
2259    ZSTD_HcFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_dictMatchState)
2260}
2261#[inline(never)]
2262unsafe fn ZSTD_HcFindBestMatch_dedicatedDictSearch_6(
2263    ms: *mut ZSTD_MatchState_t,
2264    ip: *const u8,
2265    iLimit: *const u8,
2266    offsetPtr: *mut size_t,
2267) -> size_t {
2268    ZSTD_HcFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_dedicatedDictSearch)
2269}
2270#[inline(never)]
2271unsafe fn ZSTD_HcFindBestMatch_dictMatchState_4(
2272    ms: *mut ZSTD_MatchState_t,
2273    ip: *const u8,
2274    iLimit: *const u8,
2275    offsetPtr: *mut size_t,
2276) -> size_t {
2277    ZSTD_HcFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_dictMatchState)
2278}
2279#[inline(never)]
2280unsafe fn ZSTD_HcFindBestMatch_dedicatedDictSearch_5(
2281    ms: *mut ZSTD_MatchState_t,
2282    ip: *const u8,
2283    iLimit: *const u8,
2284    offsetPtr: *mut size_t,
2285) -> size_t {
2286    ZSTD_HcFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_dedicatedDictSearch)
2287}
2288#[inline(never)]
2289unsafe fn ZSTD_HcFindBestMatch_dedicatedDictSearch_4(
2290    ms: *mut ZSTD_MatchState_t,
2291    ip: *const u8,
2292    iLimit: *const u8,
2293    offsetPtr: *mut size_t,
2294) -> size_t {
2295    ZSTD_HcFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_dedicatedDictSearch)
2296}
2297#[inline(never)]
2298unsafe fn ZSTD_HcFindBestMatch_noDict_5(
2299    ms: *mut ZSTD_MatchState_t,
2300    ip: *const u8,
2301    iLimit: *const u8,
2302    offsetPtr: *mut size_t,
2303) -> size_t {
2304    ZSTD_HcFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_noDict)
2305}
2306#[inline(never)]
2307unsafe fn ZSTD_HcFindBestMatch_dictMatchState_6(
2308    ms: *mut ZSTD_MatchState_t,
2309    ip: *const u8,
2310    iLimit: *const u8,
2311    offsetPtr: *mut size_t,
2312) -> size_t {
2313    ZSTD_HcFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_dictMatchState)
2314}
2315#[inline(never)]
2316unsafe fn ZSTD_HcFindBestMatch_noDict_4(
2317    ms: *mut ZSTD_MatchState_t,
2318    ip: *const u8,
2319    iLimit: *const u8,
2320    offsetPtr: *mut size_t,
2321) -> size_t {
2322    ZSTD_HcFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_noDict)
2323}
2324#[inline(never)]
2325unsafe fn ZSTD_HcFindBestMatch_extDict_6(
2326    ms: *mut ZSTD_MatchState_t,
2327    ip: *const u8,
2328    iLimit: *const u8,
2329    offsetPtr: *mut size_t,
2330) -> size_t {
2331    ZSTD_HcFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_extDict)
2332}
2333#[inline(never)]
2334unsafe fn ZSTD_HcFindBestMatch_extDict_5(
2335    ms: *mut ZSTD_MatchState_t,
2336    ip: *const u8,
2337    iLimit: *const u8,
2338    offsetPtr: *mut size_t,
2339) -> size_t {
2340    ZSTD_HcFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_extDict)
2341}
2342#[inline(never)]
2343unsafe fn ZSTD_HcFindBestMatch_extDict_4(
2344    ms: *mut ZSTD_MatchState_t,
2345    ip: *const u8,
2346    iLimit: *const u8,
2347    offsetPtr: *mut size_t,
2348) -> size_t {
2349    ZSTD_HcFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_extDict)
2350}
2351#[inline(always)]
2352unsafe fn ZSTD_searchMax(
2353    ms: *mut ZSTD_MatchState_t,
2354    ip: *const u8,
2355    iend: *const u8,
2356    offsetPtr: *mut size_t,
2357    mls: u32,
2358    rowLog: u32,
2359    searchMethod: searchMethod_e,
2360    dictMode: ZSTD_dictMode_e,
2361) -> size_t {
2362    if dictMode as core::ffi::c_uint == ZSTD_noDict as core::ffi::c_int as core::ffi::c_uint {
2363        match searchMethod as core::ffi::c_uint {
2364            0 => match mls {
2365                4 => return ZSTD_HcFindBestMatch_noDict_4(ms, ip, iend, offsetPtr),
2366                5 => return ZSTD_HcFindBestMatch_noDict_5(ms, ip, iend, offsetPtr),
2367                6 => return ZSTD_HcFindBestMatch_noDict_6(ms, ip, iend, offsetPtr),
2368                _ => {}
2369            },
2370            1 => match mls {
2371                4 => return ZSTD_BtFindBestMatch_noDict_4(ms, ip, iend, offsetPtr),
2372                5 => return ZSTD_BtFindBestMatch_noDict_5(ms, ip, iend, offsetPtr),
2373                6 => return ZSTD_BtFindBestMatch_noDict_6(ms, ip, iend, offsetPtr),
2374                _ => {}
2375            },
2376            2 => match mls {
2377                4 => {
2378                    match rowLog {
2379                        4 => {
2380                            return ZSTD_RowFindBestMatch_noDict_4_4(ms, ip, iend, offsetPtr);
2381                        }
2382                        5 => {
2383                            return ZSTD_RowFindBestMatch_noDict_4_5(ms, ip, iend, offsetPtr);
2384                        }
2385                        6 => {
2386                            return ZSTD_RowFindBestMatch_noDict_4_6(ms, ip, iend, offsetPtr);
2387                        }
2388                        _ => {}
2389                    }
2390                    unreachable!();
2391                }
2392                5 => {
2393                    match rowLog {
2394                        4 => {
2395                            return ZSTD_RowFindBestMatch_noDict_5_4(ms, ip, iend, offsetPtr);
2396                        }
2397                        5 => {
2398                            return ZSTD_RowFindBestMatch_noDict_5_5(ms, ip, iend, offsetPtr);
2399                        }
2400                        6 => {
2401                            return ZSTD_RowFindBestMatch_noDict_5_6(ms, ip, iend, offsetPtr);
2402                        }
2403                        _ => {}
2404                    }
2405                    unreachable!();
2406                }
2407                6 => {
2408                    match rowLog {
2409                        4 => {
2410                            return ZSTD_RowFindBestMatch_noDict_6_4(ms, ip, iend, offsetPtr);
2411                        }
2412                        5 => {
2413                            return ZSTD_RowFindBestMatch_noDict_6_5(ms, ip, iend, offsetPtr);
2414                        }
2415                        6 => {
2416                            return ZSTD_RowFindBestMatch_noDict_6_6(ms, ip, iend, offsetPtr);
2417                        }
2418                        _ => {}
2419                    }
2420                    unreachable!();
2421                }
2422                _ => {}
2423            },
2424            _ => {}
2425        }
2426        unreachable!();
2427    } else if dictMode as core::ffi::c_uint == ZSTD_extDict as core::ffi::c_int as core::ffi::c_uint
2428    {
2429        match searchMethod as core::ffi::c_uint {
2430            0 => match mls {
2431                4 => return ZSTD_HcFindBestMatch_extDict_4(ms, ip, iend, offsetPtr),
2432                5 => return ZSTD_HcFindBestMatch_extDict_5(ms, ip, iend, offsetPtr),
2433                6 => return ZSTD_HcFindBestMatch_extDict_6(ms, ip, iend, offsetPtr),
2434                _ => {}
2435            },
2436            1 => match mls {
2437                4 => return ZSTD_BtFindBestMatch_extDict_4(ms, ip, iend, offsetPtr),
2438                5 => return ZSTD_BtFindBestMatch_extDict_5(ms, ip, iend, offsetPtr),
2439                6 => return ZSTD_BtFindBestMatch_extDict_6(ms, ip, iend, offsetPtr),
2440                _ => {}
2441            },
2442            2 => match mls {
2443                4 => {
2444                    match rowLog {
2445                        4 => {
2446                            return ZSTD_RowFindBestMatch_extDict_4_4(ms, ip, iend, offsetPtr);
2447                        }
2448                        5 => {
2449                            return ZSTD_RowFindBestMatch_extDict_4_5(ms, ip, iend, offsetPtr);
2450                        }
2451                        6 => {
2452                            return ZSTD_RowFindBestMatch_extDict_4_6(ms, ip, iend, offsetPtr);
2453                        }
2454                        _ => {}
2455                    }
2456                    unreachable!();
2457                }
2458                5 => {
2459                    match rowLog {
2460                        4 => {
2461                            return ZSTD_RowFindBestMatch_extDict_5_4(ms, ip, iend, offsetPtr);
2462                        }
2463                        5 => {
2464                            return ZSTD_RowFindBestMatch_extDict_5_5(ms, ip, iend, offsetPtr);
2465                        }
2466                        6 => {
2467                            return ZSTD_RowFindBestMatch_extDict_5_6(ms, ip, iend, offsetPtr);
2468                        }
2469                        _ => {}
2470                    }
2471                    unreachable!();
2472                }
2473                6 => {
2474                    match rowLog {
2475                        4 => {
2476                            return ZSTD_RowFindBestMatch_extDict_6_4(ms, ip, iend, offsetPtr);
2477                        }
2478                        5 => {
2479                            return ZSTD_RowFindBestMatch_extDict_6_5(ms, ip, iend, offsetPtr);
2480                        }
2481                        6 => {
2482                            return ZSTD_RowFindBestMatch_extDict_6_6(ms, ip, iend, offsetPtr);
2483                        }
2484                        _ => {}
2485                    }
2486                    unreachable!();
2487                }
2488                _ => {}
2489            },
2490            _ => {}
2491        }
2492        unreachable!();
2493    } else if dictMode as core::ffi::c_uint
2494        == ZSTD_dictMatchState as core::ffi::c_int as core::ffi::c_uint
2495    {
2496        match searchMethod as core::ffi::c_uint {
2497            0 => match mls {
2498                4 => {
2499                    return ZSTD_HcFindBestMatch_dictMatchState_4(ms, ip, iend, offsetPtr);
2500                }
2501                5 => {
2502                    return ZSTD_HcFindBestMatch_dictMatchState_5(ms, ip, iend, offsetPtr);
2503                }
2504                6 => {
2505                    return ZSTD_HcFindBestMatch_dictMatchState_6(ms, ip, iend, offsetPtr);
2506                }
2507                _ => {}
2508            },
2509            1 => match mls {
2510                4 => {
2511                    return ZSTD_BtFindBestMatch_dictMatchState_4(ms, ip, iend, offsetPtr);
2512                }
2513                5 => {
2514                    return ZSTD_BtFindBestMatch_dictMatchState_5(ms, ip, iend, offsetPtr);
2515                }
2516                6 => {
2517                    return ZSTD_BtFindBestMatch_dictMatchState_6(ms, ip, iend, offsetPtr);
2518                }
2519                _ => {}
2520            },
2521            2 => match mls {
2522                4 => {
2523                    match rowLog {
2524                        4 => {
2525                            return ZSTD_RowFindBestMatch_dictMatchState_4_4(
2526                                ms, ip, iend, offsetPtr,
2527                            );
2528                        }
2529                        5 => {
2530                            return ZSTD_RowFindBestMatch_dictMatchState_4_5(
2531                                ms, ip, iend, offsetPtr,
2532                            );
2533                        }
2534                        6 => {
2535                            return ZSTD_RowFindBestMatch_dictMatchState_4_6(
2536                                ms, ip, iend, offsetPtr,
2537                            );
2538                        }
2539                        _ => {}
2540                    }
2541                    unreachable!();
2542                }
2543                5 => {
2544                    match rowLog {
2545                        4 => {
2546                            return ZSTD_RowFindBestMatch_dictMatchState_5_4(
2547                                ms, ip, iend, offsetPtr,
2548                            );
2549                        }
2550                        5 => {
2551                            return ZSTD_RowFindBestMatch_dictMatchState_5_5(
2552                                ms, ip, iend, offsetPtr,
2553                            );
2554                        }
2555                        6 => {
2556                            return ZSTD_RowFindBestMatch_dictMatchState_5_6(
2557                                ms, ip, iend, offsetPtr,
2558                            );
2559                        }
2560                        _ => {}
2561                    }
2562                    unreachable!();
2563                }
2564                6 => {
2565                    match rowLog {
2566                        4 => {
2567                            return ZSTD_RowFindBestMatch_dictMatchState_6_4(
2568                                ms, ip, iend, offsetPtr,
2569                            );
2570                        }
2571                        5 => {
2572                            return ZSTD_RowFindBestMatch_dictMatchState_6_5(
2573                                ms, ip, iend, offsetPtr,
2574                            );
2575                        }
2576                        6 => {
2577                            return ZSTD_RowFindBestMatch_dictMatchState_6_6(
2578                                ms, ip, iend, offsetPtr,
2579                            );
2580                        }
2581                        _ => {}
2582                    }
2583                    unreachable!();
2584                }
2585                _ => {}
2586            },
2587            _ => {}
2588        }
2589        unreachable!();
2590    } else if dictMode as core::ffi::c_uint
2591        == ZSTD_dedicatedDictSearch as core::ffi::c_int as core::ffi::c_uint
2592    {
2593        match searchMethod as core::ffi::c_uint {
2594            0 => match mls {
2595                4 => {
2596                    return ZSTD_HcFindBestMatch_dedicatedDictSearch_4(ms, ip, iend, offsetPtr);
2597                }
2598                5 => {
2599                    return ZSTD_HcFindBestMatch_dedicatedDictSearch_5(ms, ip, iend, offsetPtr);
2600                }
2601                6 => {
2602                    return ZSTD_HcFindBestMatch_dedicatedDictSearch_6(ms, ip, iend, offsetPtr);
2603                }
2604                _ => {}
2605            },
2606            1 => match mls {
2607                4 => {
2608                    return ZSTD_BtFindBestMatch_dedicatedDictSearch_4(ms, ip, iend, offsetPtr);
2609                }
2610                5 => {
2611                    return ZSTD_BtFindBestMatch_dedicatedDictSearch_5(ms, ip, iend, offsetPtr);
2612                }
2613                6 => {
2614                    return ZSTD_BtFindBestMatch_dedicatedDictSearch_6(ms, ip, iend, offsetPtr);
2615                }
2616                _ => {}
2617            },
2618            2 => match mls {
2619                4 => {
2620                    match rowLog {
2621                        4 => {
2622                            return ZSTD_RowFindBestMatch_dedicatedDictSearch_4_4(
2623                                ms, ip, iend, offsetPtr,
2624                            );
2625                        }
2626                        5 => {
2627                            return ZSTD_RowFindBestMatch_dedicatedDictSearch_4_5(
2628                                ms, ip, iend, offsetPtr,
2629                            );
2630                        }
2631                        6 => {
2632                            return ZSTD_RowFindBestMatch_dedicatedDictSearch_4_6(
2633                                ms, ip, iend, offsetPtr,
2634                            );
2635                        }
2636                        _ => {}
2637                    }
2638                    unreachable!();
2639                }
2640                5 => {
2641                    match rowLog {
2642                        4 => {
2643                            return ZSTD_RowFindBestMatch_dedicatedDictSearch_5_4(
2644                                ms, ip, iend, offsetPtr,
2645                            );
2646                        }
2647                        5 => {
2648                            return ZSTD_RowFindBestMatch_dedicatedDictSearch_5_5(
2649                                ms, ip, iend, offsetPtr,
2650                            );
2651                        }
2652                        6 => {
2653                            return ZSTD_RowFindBestMatch_dedicatedDictSearch_5_6(
2654                                ms, ip, iend, offsetPtr,
2655                            );
2656                        }
2657                        _ => {}
2658                    }
2659                    unreachable!();
2660                }
2661                6 => {
2662                    match rowLog {
2663                        4 => {
2664                            return ZSTD_RowFindBestMatch_dedicatedDictSearch_6_4(
2665                                ms, ip, iend, offsetPtr,
2666                            );
2667                        }
2668                        5 => {
2669                            return ZSTD_RowFindBestMatch_dedicatedDictSearch_6_5(
2670                                ms, ip, iend, offsetPtr,
2671                            );
2672                        }
2673                        6 => {
2674                            return ZSTD_RowFindBestMatch_dedicatedDictSearch_6_6(
2675                                ms, ip, iend, offsetPtr,
2676                            );
2677                        }
2678                        _ => {}
2679                    }
2680                    unreachable!();
2681                }
2682                _ => {}
2683            },
2684            _ => {}
2685        }
2686        unreachable!();
2687    }
2688    unreachable!();
2689    0
2690}
2691#[inline(always)]
2692unsafe fn ZSTD_compressBlock_lazy_generic(
2693    ms: *mut ZSTD_MatchState_t,
2694    seqStore: *mut SeqStore_t,
2695    rep: *mut u32,
2696    src: *const core::ffi::c_void,
2697    srcSize: size_t,
2698    searchMethod: searchMethod_e,
2699    depth: u32,
2700    dictMode: ZSTD_dictMode_e,
2701) -> size_t {
2702    let mut current_block: u64;
2703    let istart = src as *const u8;
2704    let mut ip = istart;
2705    let mut anchor = istart;
2706    let iend = istart.add(srcSize);
2707    let ilimit = if searchMethod as core::ffi::c_uint
2708        == search_rowHash as core::ffi::c_int as core::ffi::c_uint
2709    {
2710        iend.offset(-(8))
2711            .offset(-(ZSTD_ROW_HASH_CACHE_SIZE as isize))
2712    } else {
2713        iend.offset(-(8))
2714    };
2715    let base = (*ms).window.base;
2716    let prefixLowestIndex = (*ms).window.dictLimit;
2717    let prefixLowest = base.offset(prefixLowestIndex as isize);
2718    let mls = if 4
2719        > (if (*ms).cParams.minMatch < 6 {
2720            (*ms).cParams.minMatch
2721        } else {
2722            6
2723        }) {
2724        4
2725    } else if (*ms).cParams.minMatch < 6 {
2726        (*ms).cParams.minMatch
2727    } else {
2728        6
2729    };
2730    let rowLog = if 4
2731        > (if (*ms).cParams.searchLog < 6 {
2732            (*ms).cParams.searchLog
2733        } else {
2734            6
2735        }) {
2736        4
2737    } else if (*ms).cParams.searchLog < 6 {
2738        (*ms).cParams.searchLog
2739    } else {
2740        6
2741    };
2742    let mut offset_1 = *rep.offset(0);
2743    let mut offset_2 = *rep.offset(1);
2744    let mut offsetSaved1 = 0;
2745    let mut offsetSaved2 = 0;
2746    let isDMS = (dictMode as core::ffi::c_uint
2747        == ZSTD_dictMatchState as core::ffi::c_int as core::ffi::c_uint)
2748        as core::ffi::c_int;
2749    let isDDS = (dictMode as core::ffi::c_uint
2750        == ZSTD_dedicatedDictSearch as core::ffi::c_int as core::ffi::c_uint)
2751        as core::ffi::c_int;
2752    let isDxS = (isDMS != 0 || isDDS != 0) as core::ffi::c_int;
2753    let dms = (*ms).dictMatchState;
2754    let dictLowestIndex = if isDxS != 0 {
2755        (*dms).window.dictLimit
2756    } else {
2757        0
2758    };
2759    let dictBase = if isDxS != 0 {
2760        (*dms).window.base
2761    } else {
2762        core::ptr::null()
2763    };
2764    let dictLowest = if isDxS != 0 {
2765        dictBase.offset(dictLowestIndex as isize)
2766    } else {
2767        core::ptr::null()
2768    };
2769    let dictEnd = if isDxS != 0 {
2770        (*dms).window.nextSrc
2771    } else {
2772        core::ptr::null()
2773    };
2774    let dictIndexDelta = if isDxS != 0 {
2775        prefixLowestIndex.wrapping_sub(dictEnd.offset_from(dictBase) as core::ffi::c_long as u32)
2776    } else {
2777        0
2778    };
2779    let dictAndPrefixLength = (ip.offset_from(prefixLowest) as core::ffi::c_long
2780        + dictEnd.offset_from(dictLowest) as core::ffi::c_long)
2781        as u32;
2782    ip = ip.offset((dictAndPrefixLength == 0) as core::ffi::c_int as isize);
2783    if dictMode as core::ffi::c_uint == ZSTD_noDict as core::ffi::c_int as core::ffi::c_uint {
2784        let curr = ip.offset_from(base) as core::ffi::c_long as u32;
2785        let windowLow = ZSTD_getLowestPrefixIndex(ms, curr, (*ms).cParams.windowLog);
2786        let maxRep = curr.wrapping_sub(windowLow);
2787        if offset_2 > maxRep {
2788            offsetSaved2 = offset_2;
2789            offset_2 = 0;
2790        }
2791        if offset_1 > maxRep {
2792            offsetSaved1 = offset_1;
2793            offset_1 = 0;
2794        }
2795    }
2796    isDxS != 0;
2797    (*ms).lazySkipping = 0;
2798    if searchMethod as core::ffi::c_uint == search_rowHash as core::ffi::c_int as core::ffi::c_uint
2799    {
2800        ZSTD_row_fillHashCache(ms, base, rowLog, mls, (*ms).nextToUpdate, ilimit);
2801    }
2802
2803    #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
2804    asm!(".p2align 5", options(preserves_flags));
2805
2806    while ip < ilimit {
2807        let mut matchLength = 0;
2808        let mut offBase = REPCODE1_TO_OFFBASE as size_t;
2809        let mut start = ip.offset(1);
2810        if isDxS != 0 {
2811            let repIndex = (ip.offset_from(base) as core::ffi::c_long as u32)
2812                .wrapping_add(1)
2813                .wrapping_sub(offset_1);
2814            let repMatch = if (dictMode as core::ffi::c_uint
2815                == ZSTD_dictMatchState as core::ffi::c_int as core::ffi::c_uint
2816                || dictMode as core::ffi::c_uint
2817                    == ZSTD_dedicatedDictSearch as core::ffi::c_int as core::ffi::c_uint)
2818                && repIndex < prefixLowestIndex
2819            {
2820                dictBase.offset(repIndex.wrapping_sub(dictIndexDelta) as isize)
2821            } else {
2822                base.offset(repIndex as isize)
2823            };
2824            if ZSTD_index_overlap_check(prefixLowestIndex, repIndex) != 0
2825                && MEM_read32(repMatch as *const core::ffi::c_void)
2826                    == MEM_read32(ip.offset(1) as *const core::ffi::c_void)
2827            {
2828                let repMatchEnd = if repIndex < prefixLowestIndex {
2829                    dictEnd
2830                } else {
2831                    iend
2832                };
2833                matchLength = (ZSTD_count_2segments(
2834                    ip.offset(1).offset(4),
2835                    repMatch.offset(4),
2836                    iend,
2837                    repMatchEnd,
2838                    prefixLowest,
2839                ))
2840                .wrapping_add(4);
2841                if depth == 0 {
2842                    current_block = 9173645608424642017;
2843                } else {
2844                    current_block = 14136749492126903395;
2845                }
2846            } else {
2847                current_block = 14136749492126903395;
2848            }
2849        } else {
2850            current_block = 14136749492126903395;
2851        }
2852        if current_block == 14136749492126903395 {
2853            if dictMode as core::ffi::c_uint == ZSTD_noDict as core::ffi::c_int as core::ffi::c_uint
2854                && (offset_1 > 0) as core::ffi::c_int
2855                    & (MEM_read32(
2856                        ip.offset(1).offset(-(offset_1 as isize)) as *const core::ffi::c_void
2857                    ) == MEM_read32(ip.offset(1) as *const core::ffi::c_void))
2858                        as core::ffi::c_int
2859                    != 0
2860            {
2861                matchLength = (ZSTD_count(
2862                    ip.offset(1).offset(4),
2863                    ip.offset(1).offset(4).offset(-(offset_1 as isize)),
2864                    iend,
2865                ))
2866                .wrapping_add(4);
2867                if depth == 0 {
2868                    current_block = 9173645608424642017;
2869                } else {
2870                    current_block = 6450636197030046351;
2871                }
2872            } else {
2873                current_block = 6450636197030046351;
2874            }
2875            match current_block {
2876                9173645608424642017 => {}
2877                _ => {
2878                    let mut offbaseFound = 999999999;
2879                    let ml2 = ZSTD_searchMax(
2880                        ms,
2881                        ip,
2882                        iend,
2883                        &mut offbaseFound,
2884                        mls,
2885                        rowLog,
2886                        searchMethod,
2887                        dictMode,
2888                    );
2889                    if ml2 > matchLength {
2890                        matchLength = ml2;
2891                        start = ip;
2892                        offBase = offbaseFound;
2893                    }
2894                    if matchLength < 4 {
2895                        let step =
2896                            (ip.offset_from(anchor) as size_t >> kSearchStrength).wrapping_add(1);
2897                        ip = ip.add(step);
2898                        (*ms).lazySkipping =
2899                            (step > kLazySkippingStep as size_t) as core::ffi::c_int;
2900                        continue;
2901                    } else {
2902                        if depth >= 1 {
2903                            while ip < ilimit {
2904                                ip = ip.offset(1);
2905                                if dictMode as core::ffi::c_uint
2906                                    == ZSTD_noDict as core::ffi::c_int as core::ffi::c_uint
2907                                    && offBase != 0
2908                                    && (offset_1 > 0) as core::ffi::c_int
2909                                        & (MEM_read32(ip as *const core::ffi::c_void)
2910                                            == MEM_read32(ip.offset(-(offset_1 as isize))
2911                                                as *const core::ffi::c_void))
2912                                            as core::ffi::c_int
2913                                        != 0
2914                                {
2915                                    let mlRep = (ZSTD_count(
2916                                        ip.offset(4),
2917                                        ip.offset(4).offset(-(offset_1 as isize)),
2918                                        iend,
2919                                    ))
2920                                    .wrapping_add(4);
2921                                    let gain2 = (mlRep * 3) as core::ffi::c_int;
2922                                    let gain1 = (matchLength * 3)
2923                                        .wrapping_sub(ZSTD_highbit32(offBase as u32) as size_t)
2924                                        .wrapping_add(1)
2925                                        as core::ffi::c_int;
2926                                    if mlRep >= 4 && gain2 > gain1 {
2927                                        matchLength = mlRep;
2928                                        offBase = REPCODE1_TO_OFFBASE as size_t;
2929                                        start = ip;
2930                                    }
2931                                }
2932                                if isDxS != 0 {
2933                                    let repIndex_0 = (ip.offset_from(base) as core::ffi::c_long
2934                                        as u32)
2935                                        .wrapping_sub(offset_1);
2936                                    let repMatch_0 = if repIndex_0 < prefixLowestIndex {
2937                                        dictBase
2938                                            .offset(repIndex_0.wrapping_sub(dictIndexDelta)
2939                                                as isize)
2940                                    } else {
2941                                        base.offset(repIndex_0 as isize)
2942                                    };
2943                                    if ZSTD_index_overlap_check(prefixLowestIndex, repIndex_0) != 0
2944                                        && MEM_read32(repMatch_0 as *const core::ffi::c_void)
2945                                            == MEM_read32(ip as *const core::ffi::c_void)
2946                                    {
2947                                        let repMatchEnd_0 = if repIndex_0 < prefixLowestIndex {
2948                                            dictEnd
2949                                        } else {
2950                                            iend
2951                                        };
2952                                        let mlRep_0 = (ZSTD_count_2segments(
2953                                            ip.offset(4),
2954                                            repMatch_0.offset(4),
2955                                            iend,
2956                                            repMatchEnd_0,
2957                                            prefixLowest,
2958                                        ))
2959                                        .wrapping_add(4);
2960                                        let gain2_0 = (mlRep_0 * 3) as core::ffi::c_int;
2961                                        let gain1_0 = (matchLength * 3)
2962                                            .wrapping_sub(ZSTD_highbit32(offBase as u32) as size_t)
2963                                            .wrapping_add(1)
2964                                            as core::ffi::c_int;
2965                                        if mlRep_0 >= 4 && gain2_0 > gain1_0 {
2966                                            matchLength = mlRep_0;
2967                                            offBase = REPCODE1_TO_OFFBASE as size_t;
2968                                            start = ip;
2969                                        }
2970                                    }
2971                                }
2972                                let mut ofbCandidate = 999999999;
2973                                let ml2_0 = ZSTD_searchMax(
2974                                    ms,
2975                                    ip,
2976                                    iend,
2977                                    &mut ofbCandidate,
2978                                    mls,
2979                                    rowLog,
2980                                    searchMethod,
2981                                    dictMode,
2982                                );
2983                                let gain2_1 = (ml2_0 * 4)
2984                                    .wrapping_sub(ZSTD_highbit32(ofbCandidate as u32) as size_t)
2985                                    as core::ffi::c_int;
2986                                let gain1_1 = (matchLength * 4)
2987                                    .wrapping_sub(ZSTD_highbit32(offBase as u32) as size_t)
2988                                    .wrapping_add(4)
2989                                    as core::ffi::c_int;
2990                                if ml2_0 >= 4 && gain2_1 > gain1_1 {
2991                                    matchLength = ml2_0;
2992                                    offBase = ofbCandidate;
2993                                    start = ip;
2994                                } else {
2995                                    if !(depth == 2 && ip < ilimit) {
2996                                        break;
2997                                    }
2998                                    ip = ip.offset(1);
2999                                    if dictMode as core::ffi::c_uint
3000                                        == ZSTD_noDict as core::ffi::c_int as core::ffi::c_uint
3001                                        && offBase != 0
3002                                        && (offset_1 > 0) as core::ffi::c_int
3003                                            & (MEM_read32(ip as *const core::ffi::c_void)
3004                                                == MEM_read32(ip.offset(-(offset_1 as isize))
3005                                                    as *const core::ffi::c_void))
3006                                                as core::ffi::c_int
3007                                            != 0
3008                                    {
3009                                        let mlRep_1 = (ZSTD_count(
3010                                            ip.offset(4),
3011                                            ip.offset(4).offset(-(offset_1 as isize)),
3012                                            iend,
3013                                        ))
3014                                        .wrapping_add(4);
3015                                        let gain2_2 = (mlRep_1 * 4) as core::ffi::c_int;
3016                                        let gain1_2 = (matchLength * 4)
3017                                            .wrapping_sub(ZSTD_highbit32(offBase as u32) as size_t)
3018                                            .wrapping_add(1)
3019                                            as core::ffi::c_int;
3020                                        if mlRep_1 >= 4 && gain2_2 > gain1_2 {
3021                                            matchLength = mlRep_1;
3022                                            offBase = REPCODE1_TO_OFFBASE as size_t;
3023                                            start = ip;
3024                                        }
3025                                    }
3026                                    if isDxS != 0 {
3027                                        let repIndex_1 = (ip.offset_from(base) as core::ffi::c_long
3028                                            as u32)
3029                                            .wrapping_sub(offset_1);
3030                                        let repMatch_1 = if repIndex_1 < prefixLowestIndex {
3031                                            dictBase
3032                                                .offset(repIndex_1.wrapping_sub(dictIndexDelta)
3033                                                    as isize)
3034                                        } else {
3035                                            base.offset(repIndex_1 as isize)
3036                                        };
3037                                        if ZSTD_index_overlap_check(prefixLowestIndex, repIndex_1)
3038                                            != 0
3039                                            && MEM_read32(repMatch_1 as *const core::ffi::c_void)
3040                                                == MEM_read32(ip as *const core::ffi::c_void)
3041                                        {
3042                                            let repMatchEnd_1 = if repIndex_1 < prefixLowestIndex {
3043                                                dictEnd
3044                                            } else {
3045                                                iend
3046                                            };
3047                                            let mlRep_2 = (ZSTD_count_2segments(
3048                                                ip.offset(4),
3049                                                repMatch_1.offset(4),
3050                                                iend,
3051                                                repMatchEnd_1,
3052                                                prefixLowest,
3053                                            ))
3054                                            .wrapping_add(4);
3055                                            let gain2_3 = (mlRep_2 * 4) as core::ffi::c_int;
3056                                            let gain1_3 = (matchLength * 4)
3057                                                .wrapping_sub(
3058                                                    ZSTD_highbit32(offBase as u32) as size_t
3059                                                )
3060                                                .wrapping_add(1)
3061                                                as core::ffi::c_int;
3062                                            if mlRep_2 >= 4 && gain2_3 > gain1_3 {
3063                                                matchLength = mlRep_2;
3064                                                offBase = REPCODE1_TO_OFFBASE as size_t;
3065                                                start = ip;
3066                                            }
3067                                        }
3068                                    }
3069                                    let mut ofbCandidate_0 = 999999999;
3070                                    let ml2_1 = ZSTD_searchMax(
3071                                        ms,
3072                                        ip,
3073                                        iend,
3074                                        &mut ofbCandidate_0,
3075                                        mls,
3076                                        rowLog,
3077                                        searchMethod,
3078                                        dictMode,
3079                                    );
3080                                    let gain2_4 = (ml2_1 * 4)
3081                                        .wrapping_sub(
3082                                            ZSTD_highbit32(ofbCandidate_0 as u32) as size_t
3083                                        )
3084                                        as core::ffi::c_int;
3085                                    let gain1_4 = (matchLength * 4)
3086                                        .wrapping_sub(ZSTD_highbit32(offBase as u32) as size_t)
3087                                        .wrapping_add(7)
3088                                        as core::ffi::c_int;
3089                                    if !(ml2_1 >= 4 && gain2_4 > gain1_4) {
3090                                        break;
3091                                    }
3092                                    matchLength = ml2_1;
3093                                    offBase = ofbCandidate_0;
3094                                    start = ip;
3095                                }
3096                            }
3097                        }
3098                        if offBase > ZSTD_REP_NUM as size_t {
3099                            if dictMode as core::ffi::c_uint
3100                                == ZSTD_noDict as core::ffi::c_int as core::ffi::c_uint
3101                            {
3102                                while (start > anchor) as core::ffi::c_int
3103                                    & (start.offset(
3104                                        -(offBase.wrapping_sub(ZSTD_REP_NUM as size_t) as isize),
3105                                    ) > prefixLowest)
3106                                        as core::ffi::c_int
3107                                    != 0
3108                                    && *start.offset(-1_isize) as core::ffi::c_int
3109                                        == *start
3110                                            .offset(
3111                                                -(offBase.wrapping_sub(ZSTD_REP_NUM as size_t)
3112                                                    as isize),
3113                                            )
3114                                            .offset(-1_isize)
3115                                            as core::ffi::c_int
3116                                {
3117                                    start = start.offset(-1);
3118                                    matchLength = matchLength.wrapping_add(1);
3119                                }
3120                            }
3121                            if isDxS != 0 {
3122                                let matchIndex = (start.offset_from(base) as core::ffi::c_long
3123                                    as size_t)
3124                                    .wrapping_sub(offBase.wrapping_sub(ZSTD_REP_NUM as size_t))
3125                                    as u32;
3126                                let mut match_0 = if matchIndex < prefixLowestIndex {
3127                                    dictBase
3128                                        .offset(matchIndex as isize)
3129                                        .offset(-(dictIndexDelta as isize))
3130                                } else {
3131                                    base.offset(matchIndex as isize)
3132                                };
3133                                let mStart = if matchIndex < prefixLowestIndex {
3134                                    dictLowest
3135                                } else {
3136                                    prefixLowest
3137                                };
3138                                while start > anchor
3139                                    && match_0 > mStart
3140                                    && *start.offset(-1_isize) as core::ffi::c_int
3141                                        == *match_0.offset(-1_isize) as core::ffi::c_int
3142                                {
3143                                    start = start.offset(-1);
3144                                    match_0 = match_0.offset(-1);
3145                                    matchLength = matchLength.wrapping_add(1);
3146                                }
3147                            }
3148                            offset_2 = offset_1;
3149                            offset_1 = offBase.wrapping_sub(ZSTD_REP_NUM as size_t) as u32;
3150                        }
3151                    }
3152                }
3153            }
3154        }
3155        let litLength = start.offset_from(anchor) as size_t;
3156        ZSTD_storeSeq(
3157            seqStore,
3158            litLength,
3159            anchor,
3160            iend,
3161            offBase as u32,
3162            matchLength,
3163        );
3164        ip = start.add(matchLength);
3165        anchor = ip;
3166        if (*ms).lazySkipping != 0 {
3167            if searchMethod as core::ffi::c_uint
3168                == search_rowHash as core::ffi::c_int as core::ffi::c_uint
3169            {
3170                ZSTD_row_fillHashCache(ms, base, rowLog, mls, (*ms).nextToUpdate, ilimit);
3171            }
3172            (*ms).lazySkipping = 0;
3173        }
3174        if isDxS != 0 {
3175            while ip <= ilimit {
3176                let current2 = ip.offset_from(base) as core::ffi::c_long as u32;
3177                let repIndex_2 = current2.wrapping_sub(offset_2);
3178                let repMatch_2 = if repIndex_2 < prefixLowestIndex {
3179                    dictBase
3180                        .offset(-(dictIndexDelta as isize))
3181                        .offset(repIndex_2 as isize)
3182                } else {
3183                    base.offset(repIndex_2 as isize)
3184                };
3185                if !(ZSTD_index_overlap_check(prefixLowestIndex, repIndex_2) != 0
3186                    && MEM_read32(repMatch_2 as *const core::ffi::c_void)
3187                        == MEM_read32(ip as *const core::ffi::c_void))
3188                {
3189                    break;
3190                }
3191                let repEnd2 = if repIndex_2 < prefixLowestIndex {
3192                    dictEnd
3193                } else {
3194                    iend
3195                };
3196                matchLength = (ZSTD_count_2segments(
3197                    ip.offset(4),
3198                    repMatch_2.offset(4),
3199                    iend,
3200                    repEnd2,
3201                    prefixLowest,
3202                ))
3203                .wrapping_add(4);
3204                offBase = offset_2 as size_t;
3205                offset_2 = offset_1;
3206                offset_1 = offBase as u32;
3207                ZSTD_storeSeq(
3208                    seqStore,
3209                    0,
3210                    anchor,
3211                    iend,
3212                    REPCODE1_TO_OFFBASE as u32,
3213                    matchLength,
3214                );
3215                ip = ip.add(matchLength);
3216                anchor = ip;
3217            }
3218        }
3219        if dictMode as core::ffi::c_uint == ZSTD_noDict as core::ffi::c_int as core::ffi::c_uint {
3220            while (ip <= ilimit) as core::ffi::c_int & (offset_2 > 0) as core::ffi::c_int != 0
3221                && MEM_read32(ip as *const core::ffi::c_void)
3222                    == MEM_read32(ip.offset(-(offset_2 as isize)) as *const core::ffi::c_void)
3223            {
3224                matchLength = (ZSTD_count(
3225                    ip.offset(4),
3226                    ip.offset(4).offset(-(offset_2 as isize)),
3227                    iend,
3228                ))
3229                .wrapping_add(4);
3230                offBase = offset_2 as size_t;
3231                offset_2 = offset_1;
3232                offset_1 = offBase as u32;
3233                ZSTD_storeSeq(
3234                    seqStore,
3235                    0,
3236                    anchor,
3237                    iend,
3238                    REPCODE1_TO_OFFBASE as u32,
3239                    matchLength,
3240                );
3241                ip = ip.add(matchLength);
3242                anchor = ip;
3243            }
3244        }
3245    }
3246    offsetSaved2 = if offsetSaved1 != 0 && offset_1 != 0 {
3247        offsetSaved1
3248    } else {
3249        offsetSaved2
3250    };
3251    *rep.offset(0) = if offset_1 != 0 {
3252        offset_1
3253    } else {
3254        offsetSaved1
3255    };
3256    *rep.offset(1) = if offset_2 != 0 {
3257        offset_2
3258    } else {
3259        offsetSaved2
3260    };
3261    iend.offset_from(anchor) as size_t
3262}
3263pub unsafe fn ZSTD_compressBlock_greedy(
3264    ms: *mut ZSTD_MatchState_t,
3265    seqStore: *mut SeqStore_t,
3266    rep: *mut u32,
3267    src: *const core::ffi::c_void,
3268    srcSize: size_t,
3269) -> size_t {
3270    ZSTD_compressBlock_lazy_generic(
3271        ms,
3272        seqStore,
3273        rep,
3274        src,
3275        srcSize,
3276        search_hashChain,
3277        0,
3278        ZSTD_noDict,
3279    )
3280}
3281pub unsafe fn ZSTD_compressBlock_greedy_dictMatchState(
3282    ms: *mut ZSTD_MatchState_t,
3283    seqStore: *mut SeqStore_t,
3284    rep: *mut u32,
3285    src: *const core::ffi::c_void,
3286    srcSize: size_t,
3287) -> size_t {
3288    ZSTD_compressBlock_lazy_generic(
3289        ms,
3290        seqStore,
3291        rep,
3292        src,
3293        srcSize,
3294        search_hashChain,
3295        0,
3296        ZSTD_dictMatchState,
3297    )
3298}
3299pub unsafe fn ZSTD_compressBlock_greedy_dedicatedDictSearch(
3300    ms: *mut ZSTD_MatchState_t,
3301    seqStore: *mut SeqStore_t,
3302    rep: *mut u32,
3303    src: *const core::ffi::c_void,
3304    srcSize: size_t,
3305) -> size_t {
3306    ZSTD_compressBlock_lazy_generic(
3307        ms,
3308        seqStore,
3309        rep,
3310        src,
3311        srcSize,
3312        search_hashChain,
3313        0,
3314        ZSTD_dedicatedDictSearch,
3315    )
3316}
3317pub unsafe fn ZSTD_compressBlock_greedy_row(
3318    ms: *mut ZSTD_MatchState_t,
3319    seqStore: *mut SeqStore_t,
3320    rep: *mut u32,
3321    src: *const core::ffi::c_void,
3322    srcSize: size_t,
3323) -> size_t {
3324    ZSTD_compressBlock_lazy_generic(
3325        ms,
3326        seqStore,
3327        rep,
3328        src,
3329        srcSize,
3330        search_rowHash,
3331        0,
3332        ZSTD_noDict,
3333    )
3334}
3335pub unsafe fn ZSTD_compressBlock_greedy_dictMatchState_row(
3336    ms: *mut ZSTD_MatchState_t,
3337    seqStore: *mut SeqStore_t,
3338    rep: *mut u32,
3339    src: *const core::ffi::c_void,
3340    srcSize: size_t,
3341) -> size_t {
3342    ZSTD_compressBlock_lazy_generic(
3343        ms,
3344        seqStore,
3345        rep,
3346        src,
3347        srcSize,
3348        search_rowHash,
3349        0,
3350        ZSTD_dictMatchState,
3351    )
3352}
3353pub unsafe fn ZSTD_compressBlock_greedy_dedicatedDictSearch_row(
3354    ms: *mut ZSTD_MatchState_t,
3355    seqStore: *mut SeqStore_t,
3356    rep: *mut u32,
3357    src: *const core::ffi::c_void,
3358    srcSize: size_t,
3359) -> size_t {
3360    ZSTD_compressBlock_lazy_generic(
3361        ms,
3362        seqStore,
3363        rep,
3364        src,
3365        srcSize,
3366        search_rowHash,
3367        0,
3368        ZSTD_dedicatedDictSearch,
3369    )
3370}
3371pub unsafe fn ZSTD_compressBlock_lazy(
3372    ms: *mut ZSTD_MatchState_t,
3373    seqStore: *mut SeqStore_t,
3374    rep: *mut u32,
3375    src: *const core::ffi::c_void,
3376    srcSize: size_t,
3377) -> size_t {
3378    ZSTD_compressBlock_lazy_generic(
3379        ms,
3380        seqStore,
3381        rep,
3382        src,
3383        srcSize,
3384        search_hashChain,
3385        1,
3386        ZSTD_noDict,
3387    )
3388}
3389pub unsafe fn ZSTD_compressBlock_lazy_dictMatchState(
3390    ms: *mut ZSTD_MatchState_t,
3391    seqStore: *mut SeqStore_t,
3392    rep: *mut u32,
3393    src: *const core::ffi::c_void,
3394    srcSize: size_t,
3395) -> size_t {
3396    ZSTD_compressBlock_lazy_generic(
3397        ms,
3398        seqStore,
3399        rep,
3400        src,
3401        srcSize,
3402        search_hashChain,
3403        1,
3404        ZSTD_dictMatchState,
3405    )
3406}
3407pub unsafe fn ZSTD_compressBlock_lazy_dedicatedDictSearch(
3408    ms: *mut ZSTD_MatchState_t,
3409    seqStore: *mut SeqStore_t,
3410    rep: *mut u32,
3411    src: *const core::ffi::c_void,
3412    srcSize: size_t,
3413) -> size_t {
3414    ZSTD_compressBlock_lazy_generic(
3415        ms,
3416        seqStore,
3417        rep,
3418        src,
3419        srcSize,
3420        search_hashChain,
3421        1,
3422        ZSTD_dedicatedDictSearch,
3423    )
3424}
3425pub unsafe fn ZSTD_compressBlock_lazy_row(
3426    ms: *mut ZSTD_MatchState_t,
3427    seqStore: *mut SeqStore_t,
3428    rep: *mut u32,
3429    src: *const core::ffi::c_void,
3430    srcSize: size_t,
3431) -> size_t {
3432    ZSTD_compressBlock_lazy_generic(
3433        ms,
3434        seqStore,
3435        rep,
3436        src,
3437        srcSize,
3438        search_rowHash,
3439        1,
3440        ZSTD_noDict,
3441    )
3442}
3443pub unsafe fn ZSTD_compressBlock_lazy_dictMatchState_row(
3444    ms: *mut ZSTD_MatchState_t,
3445    seqStore: *mut SeqStore_t,
3446    rep: *mut u32,
3447    src: *const core::ffi::c_void,
3448    srcSize: size_t,
3449) -> size_t {
3450    ZSTD_compressBlock_lazy_generic(
3451        ms,
3452        seqStore,
3453        rep,
3454        src,
3455        srcSize,
3456        search_rowHash,
3457        1,
3458        ZSTD_dictMatchState,
3459    )
3460}
3461pub unsafe fn ZSTD_compressBlock_lazy_dedicatedDictSearch_row(
3462    ms: *mut ZSTD_MatchState_t,
3463    seqStore: *mut SeqStore_t,
3464    rep: *mut u32,
3465    src: *const core::ffi::c_void,
3466    srcSize: size_t,
3467) -> size_t {
3468    ZSTD_compressBlock_lazy_generic(
3469        ms,
3470        seqStore,
3471        rep,
3472        src,
3473        srcSize,
3474        search_rowHash,
3475        1,
3476        ZSTD_dedicatedDictSearch,
3477    )
3478}
3479pub unsafe fn ZSTD_compressBlock_lazy2(
3480    ms: *mut ZSTD_MatchState_t,
3481    seqStore: *mut SeqStore_t,
3482    rep: *mut u32,
3483    src: *const core::ffi::c_void,
3484    srcSize: size_t,
3485) -> size_t {
3486    ZSTD_compressBlock_lazy_generic(
3487        ms,
3488        seqStore,
3489        rep,
3490        src,
3491        srcSize,
3492        search_hashChain,
3493        2,
3494        ZSTD_noDict,
3495    )
3496}
3497pub unsafe fn ZSTD_compressBlock_lazy2_dictMatchState(
3498    ms: *mut ZSTD_MatchState_t,
3499    seqStore: *mut SeqStore_t,
3500    rep: *mut u32,
3501    src: *const core::ffi::c_void,
3502    srcSize: size_t,
3503) -> size_t {
3504    ZSTD_compressBlock_lazy_generic(
3505        ms,
3506        seqStore,
3507        rep,
3508        src,
3509        srcSize,
3510        search_hashChain,
3511        2,
3512        ZSTD_dictMatchState,
3513    )
3514}
3515pub unsafe fn ZSTD_compressBlock_lazy2_dedicatedDictSearch(
3516    ms: *mut ZSTD_MatchState_t,
3517    seqStore: *mut SeqStore_t,
3518    rep: *mut u32,
3519    src: *const core::ffi::c_void,
3520    srcSize: size_t,
3521) -> size_t {
3522    ZSTD_compressBlock_lazy_generic(
3523        ms,
3524        seqStore,
3525        rep,
3526        src,
3527        srcSize,
3528        search_hashChain,
3529        2,
3530        ZSTD_dedicatedDictSearch,
3531    )
3532}
3533pub unsafe fn ZSTD_compressBlock_lazy2_row(
3534    ms: *mut ZSTD_MatchState_t,
3535    seqStore: *mut SeqStore_t,
3536    rep: *mut u32,
3537    src: *const core::ffi::c_void,
3538    srcSize: size_t,
3539) -> size_t {
3540    ZSTD_compressBlock_lazy_generic(
3541        ms,
3542        seqStore,
3543        rep,
3544        src,
3545        srcSize,
3546        search_rowHash,
3547        2,
3548        ZSTD_noDict,
3549    )
3550}
3551pub unsafe fn ZSTD_compressBlock_lazy2_dictMatchState_row(
3552    ms: *mut ZSTD_MatchState_t,
3553    seqStore: *mut SeqStore_t,
3554    rep: *mut u32,
3555    src: *const core::ffi::c_void,
3556    srcSize: size_t,
3557) -> size_t {
3558    ZSTD_compressBlock_lazy_generic(
3559        ms,
3560        seqStore,
3561        rep,
3562        src,
3563        srcSize,
3564        search_rowHash,
3565        2,
3566        ZSTD_dictMatchState,
3567    )
3568}
3569pub unsafe fn ZSTD_compressBlock_lazy2_dedicatedDictSearch_row(
3570    ms: *mut ZSTD_MatchState_t,
3571    seqStore: *mut SeqStore_t,
3572    rep: *mut u32,
3573    src: *const core::ffi::c_void,
3574    srcSize: size_t,
3575) -> size_t {
3576    ZSTD_compressBlock_lazy_generic(
3577        ms,
3578        seqStore,
3579        rep,
3580        src,
3581        srcSize,
3582        search_rowHash,
3583        2,
3584        ZSTD_dedicatedDictSearch,
3585    )
3586}
3587pub unsafe fn ZSTD_compressBlock_btlazy2(
3588    ms: *mut ZSTD_MatchState_t,
3589    seqStore: *mut SeqStore_t,
3590    rep: *mut u32,
3591    src: *const core::ffi::c_void,
3592    srcSize: size_t,
3593) -> size_t {
3594    ZSTD_compressBlock_lazy_generic(
3595        ms,
3596        seqStore,
3597        rep,
3598        src,
3599        srcSize,
3600        search_binaryTree,
3601        2,
3602        ZSTD_noDict,
3603    )
3604}
3605pub unsafe fn ZSTD_compressBlock_btlazy2_dictMatchState(
3606    ms: *mut ZSTD_MatchState_t,
3607    seqStore: *mut SeqStore_t,
3608    rep: *mut u32,
3609    src: *const core::ffi::c_void,
3610    srcSize: size_t,
3611) -> size_t {
3612    ZSTD_compressBlock_lazy_generic(
3613        ms,
3614        seqStore,
3615        rep,
3616        src,
3617        srcSize,
3618        search_binaryTree,
3619        2,
3620        ZSTD_dictMatchState,
3621    )
3622}
3623#[inline(always)]
3624unsafe fn ZSTD_compressBlock_lazy_extDict_generic(
3625    ms: *mut ZSTD_MatchState_t,
3626    seqStore: *mut SeqStore_t,
3627    rep: *mut u32,
3628    src: *const core::ffi::c_void,
3629    srcSize: size_t,
3630    searchMethod: searchMethod_e,
3631    depth: u32,
3632) -> size_t {
3633    let istart = src as *const u8;
3634    let mut ip = istart;
3635    let mut anchor = istart;
3636    let iend = istart.add(srcSize);
3637    let ilimit = if searchMethod as core::ffi::c_uint
3638        == search_rowHash as core::ffi::c_int as core::ffi::c_uint
3639    {
3640        iend.offset(-(8))
3641            .offset(-(ZSTD_ROW_HASH_CACHE_SIZE as isize))
3642    } else {
3643        iend.offset(-(8))
3644    };
3645    let base = (*ms).window.base;
3646    let dictLimit = (*ms).window.dictLimit;
3647    let prefixStart = base.offset(dictLimit as isize);
3648    let dictBase = (*ms).window.dictBase;
3649    let dictEnd = dictBase.offset(dictLimit as isize);
3650    let dictStart = dictBase.offset((*ms).window.lowLimit as isize);
3651    let windowLog = (*ms).cParams.windowLog;
3652    let mls = if 4
3653        > (if (*ms).cParams.minMatch < 6 {
3654            (*ms).cParams.minMatch
3655        } else {
3656            6
3657        }) {
3658        4
3659    } else if (*ms).cParams.minMatch < 6 {
3660        (*ms).cParams.minMatch
3661    } else {
3662        6
3663    };
3664    let rowLog = if 4
3665        > (if (*ms).cParams.searchLog < 6 {
3666            (*ms).cParams.searchLog
3667        } else {
3668            6
3669        }) {
3670        4
3671    } else if (*ms).cParams.searchLog < 6 {
3672        (*ms).cParams.searchLog
3673    } else {
3674        6
3675    };
3676    let mut offset_1 = *rep.offset(0);
3677    let mut offset_2 = *rep.offset(1);
3678    (*ms).lazySkipping = 0;
3679    ip = ip.offset((ip == prefixStart) as core::ffi::c_int as isize);
3680    if searchMethod as core::ffi::c_uint == search_rowHash as core::ffi::c_int as core::ffi::c_uint
3681    {
3682        ZSTD_row_fillHashCache(ms, base, rowLog, mls, (*ms).nextToUpdate, ilimit);
3683    }
3684
3685    #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
3686    asm!(".p2align 5", options(preserves_flags, att_syntax));
3687
3688    let mut current_block_61: u64;
3689    while ip < ilimit {
3690        let mut matchLength = 0;
3691        let mut offBase = REPCODE1_TO_OFFBASE as size_t;
3692        let mut start = ip.offset(1);
3693        let mut curr = ip.offset_from(base) as core::ffi::c_long as u32;
3694        let windowLow = ZSTD_getLowestMatchIndex(ms, curr.wrapping_add(1), windowLog);
3695        let repIndex = curr.wrapping_add(1).wrapping_sub(offset_1);
3696        let repBase = if repIndex < dictLimit { dictBase } else { base };
3697        let repMatch = repBase.offset(repIndex as isize);
3698        if ZSTD_index_overlap_check(dictLimit, repIndex)
3699            & (offset_1 <= curr.wrapping_add(1).wrapping_sub(windowLow)) as core::ffi::c_int
3700            != 0
3701        {
3702            if MEM_read32(ip.offset(1) as *const core::ffi::c_void)
3703                == MEM_read32(repMatch as *const core::ffi::c_void)
3704            {
3705                let repEnd = if repIndex < dictLimit { dictEnd } else { iend };
3706                matchLength = (ZSTD_count_2segments(
3707                    ip.offset(1).offset(4),
3708                    repMatch.offset(4),
3709                    iend,
3710                    repEnd,
3711                    prefixStart,
3712                ))
3713                .wrapping_add(4);
3714                if depth == 0 {
3715                    current_block_61 = 10962704168502628720;
3716                } else {
3717                    current_block_61 = 12147880666119273379;
3718                }
3719            } else {
3720                current_block_61 = 12147880666119273379;
3721            }
3722        } else {
3723            current_block_61 = 12147880666119273379;
3724        }
3725        if current_block_61 == 12147880666119273379 {
3726            let mut ofbCandidate = 999999999;
3727            let ml2 = ZSTD_searchMax(
3728                ms,
3729                ip,
3730                iend,
3731                &mut ofbCandidate,
3732                mls,
3733                rowLog,
3734                searchMethod,
3735                ZSTD_extDict,
3736            );
3737            if ml2 > matchLength {
3738                matchLength = ml2;
3739                start = ip;
3740                offBase = ofbCandidate;
3741            }
3742            if matchLength < 4 {
3743                let step = ip.offset_from(anchor) as size_t >> kSearchStrength;
3744                ip = ip.add(step.wrapping_add(1));
3745                (*ms).lazySkipping = (step > kLazySkippingStep as size_t) as core::ffi::c_int;
3746                continue;
3747            } else {
3748                if depth >= 1 {
3749                    while ip < ilimit {
3750                        ip = ip.offset(1);
3751                        curr = curr.wrapping_add(1);
3752                        if offBase != 0 {
3753                            let windowLow_0 = ZSTD_getLowestMatchIndex(ms, curr, windowLog);
3754                            let repIndex_0 = curr.wrapping_sub(offset_1);
3755                            let repBase_0 = if repIndex_0 < dictLimit {
3756                                dictBase
3757                            } else {
3758                                base
3759                            };
3760                            let repMatch_0 = repBase_0.offset(repIndex_0 as isize);
3761                            if ZSTD_index_overlap_check(dictLimit, repIndex_0)
3762                                & (offset_1 <= curr.wrapping_sub(windowLow_0)) as core::ffi::c_int
3763                                != 0
3764                                && MEM_read32(ip as *const core::ffi::c_void)
3765                                    == MEM_read32(repMatch_0 as *const core::ffi::c_void)
3766                            {
3767                                let repEnd_0 = if repIndex_0 < dictLimit {
3768                                    dictEnd
3769                                } else {
3770                                    iend
3771                                };
3772                                let repLength = (ZSTD_count_2segments(
3773                                    ip.offset(4),
3774                                    repMatch_0.offset(4),
3775                                    iend,
3776                                    repEnd_0,
3777                                    prefixStart,
3778                                ))
3779                                .wrapping_add(4);
3780                                let gain2 = (repLength * 3) as core::ffi::c_int;
3781                                let gain1 = (matchLength * 3)
3782                                    .wrapping_sub(ZSTD_highbit32(offBase as u32) as size_t)
3783                                    .wrapping_add(1)
3784                                    as core::ffi::c_int;
3785                                if repLength >= 4 && gain2 > gain1 {
3786                                    matchLength = repLength;
3787                                    offBase = REPCODE1_TO_OFFBASE as size_t;
3788                                    start = ip;
3789                                }
3790                            }
3791                        }
3792                        let mut ofbCandidate_0 = 999999999;
3793                        let ml2_0 = ZSTD_searchMax(
3794                            ms,
3795                            ip,
3796                            iend,
3797                            &mut ofbCandidate_0,
3798                            mls,
3799                            rowLog,
3800                            searchMethod,
3801                            ZSTD_extDict,
3802                        );
3803                        let gain2_0 = (ml2_0 * 4)
3804                            .wrapping_sub(ZSTD_highbit32(ofbCandidate_0 as u32) as size_t)
3805                            as core::ffi::c_int;
3806                        let gain1_0 = (matchLength * 4)
3807                            .wrapping_sub(ZSTD_highbit32(offBase as u32) as size_t)
3808                            .wrapping_add(4)
3809                            as core::ffi::c_int;
3810                        if ml2_0 >= 4 && gain2_0 > gain1_0 {
3811                            matchLength = ml2_0;
3812                            offBase = ofbCandidate_0;
3813                            start = ip;
3814                        } else {
3815                            if !(depth == 2 && ip < ilimit) {
3816                                break;
3817                            }
3818                            ip = ip.offset(1);
3819                            curr = curr.wrapping_add(1);
3820                            if offBase != 0 {
3821                                let windowLow_1 = ZSTD_getLowestMatchIndex(ms, curr, windowLog);
3822                                let repIndex_1 = curr.wrapping_sub(offset_1);
3823                                let repBase_1 = if repIndex_1 < dictLimit {
3824                                    dictBase
3825                                } else {
3826                                    base
3827                                };
3828                                let repMatch_1 = repBase_1.offset(repIndex_1 as isize);
3829                                if ZSTD_index_overlap_check(dictLimit, repIndex_1)
3830                                    & (offset_1 <= curr.wrapping_sub(windowLow_1))
3831                                        as core::ffi::c_int
3832                                    != 0
3833                                    && MEM_read32(ip as *const core::ffi::c_void)
3834                                        == MEM_read32(repMatch_1 as *const core::ffi::c_void)
3835                                {
3836                                    let repEnd_1 = if repIndex_1 < dictLimit {
3837                                        dictEnd
3838                                    } else {
3839                                        iend
3840                                    };
3841                                    let repLength_0 = (ZSTD_count_2segments(
3842                                        ip.offset(4),
3843                                        repMatch_1.offset(4),
3844                                        iend,
3845                                        repEnd_1,
3846                                        prefixStart,
3847                                    ))
3848                                    .wrapping_add(4);
3849                                    let gain2_1 = (repLength_0 * 4) as core::ffi::c_int;
3850                                    let gain1_1 = (matchLength * 4)
3851                                        .wrapping_sub(ZSTD_highbit32(offBase as u32) as size_t)
3852                                        .wrapping_add(1)
3853                                        as core::ffi::c_int;
3854                                    if repLength_0 >= 4 && gain2_1 > gain1_1 {
3855                                        matchLength = repLength_0;
3856                                        offBase = REPCODE1_TO_OFFBASE as size_t;
3857                                        start = ip;
3858                                    }
3859                                }
3860                            }
3861                            let mut ofbCandidate_1 = 999999999;
3862                            let ml2_1 = ZSTD_searchMax(
3863                                ms,
3864                                ip,
3865                                iend,
3866                                &mut ofbCandidate_1,
3867                                mls,
3868                                rowLog,
3869                                searchMethod,
3870                                ZSTD_extDict,
3871                            );
3872                            let gain2_2 = (ml2_1 * 4)
3873                                .wrapping_sub(ZSTD_highbit32(ofbCandidate_1 as u32) as size_t)
3874                                as core::ffi::c_int;
3875                            let gain1_2 = (matchLength * 4)
3876                                .wrapping_sub(ZSTD_highbit32(offBase as u32) as size_t)
3877                                .wrapping_add(7)
3878                                as core::ffi::c_int;
3879                            if !(ml2_1 >= 4 && gain2_2 > gain1_2) {
3880                                break;
3881                            }
3882                            matchLength = ml2_1;
3883                            offBase = ofbCandidate_1;
3884                            start = ip;
3885                        }
3886                    }
3887                }
3888                if offBase > ZSTD_REP_NUM as size_t {
3889                    let matchIndex = (start.offset_from(base) as size_t)
3890                        .wrapping_sub(offBase.wrapping_sub(ZSTD_REP_NUM as size_t))
3891                        as u32;
3892                    let mut match_0 = if matchIndex < dictLimit {
3893                        dictBase.offset(matchIndex as isize)
3894                    } else {
3895                        base.offset(matchIndex as isize)
3896                    };
3897                    let mStart = if matchIndex < dictLimit {
3898                        dictStart
3899                    } else {
3900                        prefixStart
3901                    };
3902                    while start > anchor
3903                        && match_0 > mStart
3904                        && *start.offset(-1_isize) as core::ffi::c_int
3905                            == *match_0.offset(-1_isize) as core::ffi::c_int
3906                    {
3907                        start = start.offset(-1);
3908                        match_0 = match_0.offset(-1);
3909                        matchLength = matchLength.wrapping_add(1);
3910                    }
3911                    offset_2 = offset_1;
3912                    offset_1 = offBase.wrapping_sub(ZSTD_REP_NUM as size_t) as u32;
3913                }
3914            }
3915        }
3916        let litLength = start.offset_from(anchor) as size_t;
3917        ZSTD_storeSeq(
3918            seqStore,
3919            litLength,
3920            anchor,
3921            iend,
3922            offBase as u32,
3923            matchLength,
3924        );
3925        ip = start.add(matchLength);
3926        anchor = ip;
3927        if (*ms).lazySkipping != 0 {
3928            if searchMethod as core::ffi::c_uint
3929                == search_rowHash as core::ffi::c_int as core::ffi::c_uint
3930            {
3931                ZSTD_row_fillHashCache(ms, base, rowLog, mls, (*ms).nextToUpdate, ilimit);
3932            }
3933            (*ms).lazySkipping = 0;
3934        }
3935        while ip <= ilimit {
3936            let repCurrent = ip.offset_from(base) as core::ffi::c_long as u32;
3937            let windowLow_2 = ZSTD_getLowestMatchIndex(ms, repCurrent, windowLog);
3938            let repIndex_2 = repCurrent.wrapping_sub(offset_2);
3939            let repBase_2 = if repIndex_2 < dictLimit {
3940                dictBase
3941            } else {
3942                base
3943            };
3944            let repMatch_2 = repBase_2.offset(repIndex_2 as isize);
3945            if ZSTD_index_overlap_check(dictLimit, repIndex_2)
3946                & (offset_2 <= repCurrent.wrapping_sub(windowLow_2)) as core::ffi::c_int
3947                == 0
3948            {
3949                break;
3950            }
3951            if MEM_read32(ip as *const core::ffi::c_void)
3952                != MEM_read32(repMatch_2 as *const core::ffi::c_void)
3953            {
3954                break;
3955            }
3956            let repEnd_2 = if repIndex_2 < dictLimit {
3957                dictEnd
3958            } else {
3959                iend
3960            };
3961            matchLength = (ZSTD_count_2segments(
3962                ip.offset(4),
3963                repMatch_2.offset(4),
3964                iend,
3965                repEnd_2,
3966                prefixStart,
3967            ))
3968            .wrapping_add(4);
3969            offBase = offset_2 as size_t;
3970            offset_2 = offset_1;
3971            offset_1 = offBase as u32;
3972            ZSTD_storeSeq(
3973                seqStore,
3974                0,
3975                anchor,
3976                iend,
3977                REPCODE1_TO_OFFBASE as u32,
3978                matchLength,
3979            );
3980            ip = ip.add(matchLength);
3981            anchor = ip;
3982        }
3983    }
3984    *rep.offset(0) = offset_1;
3985    *rep.offset(1) = offset_2;
3986    iend.offset_from(anchor) as size_t
3987}
3988pub unsafe fn ZSTD_compressBlock_greedy_extDict(
3989    ms: *mut ZSTD_MatchState_t,
3990    seqStore: *mut SeqStore_t,
3991    rep: *mut u32,
3992    src: *const core::ffi::c_void,
3993    srcSize: size_t,
3994) -> size_t {
3995    ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, search_hashChain, 0)
3996}
3997pub unsafe fn ZSTD_compressBlock_greedy_extDict_row(
3998    ms: *mut ZSTD_MatchState_t,
3999    seqStore: *mut SeqStore_t,
4000    rep: *mut u32,
4001    src: *const core::ffi::c_void,
4002    srcSize: size_t,
4003) -> size_t {
4004    ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, search_rowHash, 0)
4005}
4006pub unsafe fn ZSTD_compressBlock_lazy_extDict(
4007    ms: *mut ZSTD_MatchState_t,
4008    seqStore: *mut SeqStore_t,
4009    rep: *mut u32,
4010    src: *const core::ffi::c_void,
4011    srcSize: size_t,
4012) -> size_t {
4013    ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, search_hashChain, 1)
4014}
4015pub unsafe fn ZSTD_compressBlock_lazy_extDict_row(
4016    ms: *mut ZSTD_MatchState_t,
4017    seqStore: *mut SeqStore_t,
4018    rep: *mut u32,
4019    src: *const core::ffi::c_void,
4020    srcSize: size_t,
4021) -> size_t {
4022    ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, search_rowHash, 1)
4023}
4024pub unsafe fn ZSTD_compressBlock_lazy2_extDict(
4025    ms: *mut ZSTD_MatchState_t,
4026    seqStore: *mut SeqStore_t,
4027    rep: *mut u32,
4028    src: *const core::ffi::c_void,
4029    srcSize: size_t,
4030) -> size_t {
4031    ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, search_hashChain, 2)
4032}
4033pub unsafe fn ZSTD_compressBlock_lazy2_extDict_row(
4034    ms: *mut ZSTD_MatchState_t,
4035    seqStore: *mut SeqStore_t,
4036    rep: *mut u32,
4037    src: *const core::ffi::c_void,
4038    srcSize: size_t,
4039) -> size_t {
4040    ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, search_rowHash, 2)
4041}
4042pub unsafe fn ZSTD_compressBlock_btlazy2_extDict(
4043    ms: *mut ZSTD_MatchState_t,
4044    seqStore: *mut SeqStore_t,
4045    rep: *mut u32,
4046    src: *const core::ffi::c_void,
4047    srcSize: size_t,
4048) -> size_t {
4049    ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, search_binaryTree, 2)
4050}