// File: /workspace/github_c_makefile_star2_O3/dolphinking[P]slimox/src/slimox-codec.c
// Function: lzmatch_thread
static inline void* lzmatch_thread(lzmatch_thread_param_pack_t* args) { /* thread for finding matches */
    uint32_t match_len;
    uint32_t mpos = args->m_mpos[0];
    uint32_t midx = 0;
    uint32_t i;

    while(mpos < args->m_ib->m_size && midx < MLEN_SIZE) {
        match_len = 1;
        if(mpos > 16 && mpos + 512 < args->m_ib->m_size) { /* find a match -- avoid overflow */
            match_len = matcher_lookup(args->m_matcher, args->m_ib->m_data, mpos);
            if(match_len < match_min) {
                match_len = 1;
            }
            for(i = 0; i < match_len; i++) {
                matcher_update(args->m_matcher, args->m_ib->m_data, mpos + i, 1);
            }
        }
        mpos += match_len;
        args->m_mlen[midx++] = match_len;
    }

    if(midx < MLEN_SIZE) { /* put an END flag */
        args->m_mlen[midx++] = 0;
    }
    args->m_mpos[0] = mpos;
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0x8(%rdi), %rsi
movq 0x18(%rdi), %rdx
movl (%rdx), %ecx
movl 0x8(%rsi), %r8d
cmpl %r8d, %ecx
jae 0x6d6d
movq %rdx, -0x20(%rsp)
movq 0x10(%rdi), %rdx
xorl %r11d, %r11d
movl $0xfffff, %r9d          # imm = 0xFFFFF
movq %rdi, -0x8(%rsp)
movq %rsi, -0x10(%rsp)
movq %rdx, -0x18(%rsp)
movq %r11, %r10
movl $0x1, %r15d
cmpl $0x11, %ecx
jb 0x6d3c
leal 0x200(%rcx), %eax
movl $0x1, %r15d
cmpl %r8d, %eax
jae 0x6d3c
movq (%rdi), %r11
movq (%rsi), %rbx
movl %ecx, %r12d
movl -0x4(%rbx,%r12), %r15d
movq (%r11), %r14
movq -0x8(%rbx,%r12), %rax
movq %rax, %r8
shrq $0x16, %r8
movq %rax, %r13
shrq $0x2c, %r13
xorl %r8d, %r13d
movl %eax, %r8d
xorl %r13d, %r8d
andl $0xfffff, %r8d          # imm = 0xFFFFF
movq (%r14,%r8,8), %r8
movq %r8, %r13
shrq $0x20, %r13
cmpl %r15d, %r13d
sete %bpl
testl %r8d, %r8d
setne %r13b
testb %r13b, %bpl
jne 0x6c2e
shrq $0x30, %rax
movq 0x8(%r11), %r8
movq 0x10(%r11), %r13
movl (%r13,%rax,4), %eax
movl %r15d, %ebp
shrl $0x6, %ebp
movl %r15d, %r13d
shrl $0xc, %r13d
xorl %ebp, %r13d
xorl %r15d, %r13d
andl $0xfffff, %r13d         # imm = 0xFFFFF
movq (%r8,%r13,8), %r13
movq %r13, %rbp
shrq $0x20, %rbp
testl %r13d, %r13d
movl %eax, %r8d
cmovnel %r13d, %r8d
cmpl %r15d, %ebp
cmovnel %eax, %r8d
testl %r8d, %r8d
je 0x6c69
movl %r8d, %eax
xorl %r15d, %r15d
leal (%rax,%r15), %r8d
movb (%rbx,%r8), %r8b
leal (%r12,%r15), %r13d
cmpb (%rbx,%r13), %r8b
jne 0x6c5a
incq %r15
cmpq $0xff, %r15
jne 0x6c34
movl $0xff, %r15d
jmp 0x6c6f
cmpl $0x8, %r15d
movl $0x1, %eax
cmovbl %eax, %r15d
jmp 0x6c6f
movl $0x1, %r15d
cmpl $0x1, %r15d
movl %r15d, %r12d
adcl $0x0, %r12d
movl %ecx, %ebp
cmpl $0xc, %ebp
jb 0x6d22
movl %ebp, %r13d
movl -0x4(%rbx,%r13), %esi
movl %esi, %r8d
shrl $0x6, %r8d
movl %esi, %eax
shrl $0xc, %eax
xorl %r8d, %eax
xorl %esi, %eax
shlq $0x20, %rsi
orq %r13, %rsi
movq -0x8(%rbx,%r13), %rdx
movq %rdx, %r8
shrq $0x16, %r8
movq %rdx, %rdi
shrq $0x2c, %rdi
xorl %edi, %r8d
movl %edx, %edi
xorl %r8d, %edi
andl %r9d, %edi
movq %rsi, (%r14,%rdi,8)
movq 0x8(%r11), %r8
andl %r9d, %eax
movq %rsi, (%r8,%rax,8)
movq 0x10(%r11), %rax
shrq $0x30, %rdx
movl %ebp, (%rax,%rdx,4)
movq -0x6(%rbx,%r13), %r13
movq %r13, %rdx
shrq $0x16, %rdx
movq %r13, %rsi
shrq $0x2c, %rsi
xorl %esi, %edx
movl %r13d, %edi
xorl %edx, %edi
andl %r9d, %edi
prefetcht0 (%r14,%rdi,8)
movq %r13, %rdx
shrq $0x20, %rdx
movq %r13, %rdi
shrq $0x26, %rdi
xorl %esi, %edi
xorl %edx, %edi
andl %r9d, %edi
prefetcht0 (%r8,%rdi,8)
shrq $0x30, %r13
prefetcht0 (%rax,%r13,4)
incl %ebp
decq %r12
jne 0x6c7c
movq -0x8(%rsp), %rdi
movq -0x10(%rsp), %rsi
movq -0x18(%rsp), %rdx
addl %r15d, %ecx
leaq 0x1(%r10), %r11
movl %r15d, (%rdx,%r10,4)
movl 0x8(%rsi), %r8d
cmpl %r8d, %ecx
jae 0x6d5d
cmpq $0xf9ff, %r10           # imm = 0xF9FF
jb 0x6b69
cmpq $0xf9fe, %r10           # imm = 0xF9FE
movq -0x20(%rsp), %rdx
jbe 0x6d70
jmp 0x6d7c
xorl %r11d, %r11d
movq 0x10(%rdi), %rax
movl $0x0, (%rax,%r11,4)
movl %ecx, (%rdx)
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq