// File: /workspace/github_c_makefile_star2_O1/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), %rdx
movq 0x18(%rdi), %rsi
movl (%rsi), %ecx
movl 0x8(%rdx), %r11d
cmpl %r11d, %ecx
jae 0x6843
movq %rsi, -0x20(%rsp)
movq 0x10(%rdi), %rsi
xorl %r8d, %r8d
movl $0xfffff, %r10d         # imm = 0xFFFFF
movq %rdi, -0x8(%rsp)
movq %rdx, -0x10(%rsp)
movq %rsi, -0x18(%rsp)
movl $0x1, %r15d
cmpl $0x11, %ecx
jb 0x680b
leal 0x200(%rcx), %eax
movl $0x1, %r15d
cmpl %r11d, %eax
jae 0x680b
movq (%rdi), %r11
movq (%rdx), %rbx
movl %ecx, %r12d
movl -0x4(%rbx,%r12), %r15d
movq (%r11), %r14
movq -0x8(%rbx,%r12), %rax
movq %rax, %r9
shrq $0x16, %r9
movq %rax, %r13
shrq $0x2c, %r13
xorl %r9d, %r13d
xorl %r13d, %eax
andl $0xfffff, %eax          # imm = 0xFFFFF
movq (%r14,%rax,8), %r13
movq %r13, %rax
shrq $0x20, %rax
cmpl %r15d, %eax
sete %al
testl %r13d, %r13d
setne %r9b
testb %r9b, %al
jne 0x66f5
movq 0x8(%r11), %rax
movq 0x10(%r11), %r9
movzwl -0x2(%rbx,%r12), %r13d
movl (%r9,%r13,4), %r9d
movl %r15d, %ebp
shrl $0x6, %ebp
movl %r15d, %r13d
shrl $0xc, %r13d
xorl %ebp, %r13d
xorl %r15d, %r13d
andl $0xfffff, %r13d         # imm = 0xFFFFF
movq (%rax,%r13,8), %rax
movq %rax, %rbp
shrq $0x20, %rbp
testl %eax, %eax
movl %r9d, %r13d
cmovnel %eax, %r13d
cmpl %r15d, %ebp
cmovnel %r9d, %r13d
testl %r13d, %r13d
je 0x6729
movl %r13d, %eax
xorl %r9d, %r9d
leal (%rax,%r9), %r15d
movb (%rbx,%r15), %bpl
leal (%r12,%r9), %r15d
cmpb (%rbx,%r15), %bpl
jne 0x672e
leaq 0x1(%r9), %r15
testl %r13d, %r13d
je 0x6731
cmpq $0xfe, %r9
movq %r15, %r9
jb 0x6700
jmp 0x6731
xorl %r15d, %r15d
jmp 0x6731
movq %r9, %r15
cmpl $0x8, %r15d
movl $0x1, %eax
cmovbl %eax, %r15d
cmpl $0x1, %r15d
movl %r15d, %r12d
adcl $0x0, %r12d
movl %ecx, %ebp
cmpl $0xc, %ebp
jb 0x67f1
movl %ebp, %r13d
movl -0x4(%rbx,%r13), %esi
movl %esi, %r9d
shrl $0x6, %r9d
movl %esi, %eax
shrl $0xc, %eax
xorl %r9d, %eax
xorl %esi, %eax
movq %rsi, %r9
shlq $0x20, %r9
orq %r13, %r9
movq -0x8(%rbx,%r13), %rdi
movq %rdi, %rdx
shrq $0x16, %rdx
movq %rdi, %rsi
shrq $0x2c, %rsi
xorl %esi, %edx
xorl %edx, %edi
andl %r10d, %edi
movq %r9, (%r14,%rdi,8)
movq 0x8(%r11), %rsi
andl %r10d, %eax
movq %r9, (%rsi,%rax,8)
movq 0x10(%r11), %r9
movzwl -0x2(%rbx,%r13), %eax
movl %ebp, (%r9,%rax,4)
movq -0x6(%rbx,%r13), %rax
movq %rax, %rdx
shrq $0x16, %rdx
movq %rax, %rdi
shrq $0x2c, %rdi
xorl %edi, %edx
xorl %edx, %eax
andl %r10d, %eax
prefetcht0 (%r14,%rax,8)
movl -0x2(%rbx,%r13), %eax
movl %eax, %edx
shrl $0x6, %edx
movl %eax, %edi
shrl $0xc, %edi
xorl %edx, %edi
xorl %eax, %edi
andl %r10d, %edi
prefetcht0 (%rsi,%rdi,8)
movzwl (%rbx,%r13), %eax
prefetcht0 (%r9,%rax,4)
incl %ebp
decq %r12
jne 0x674b
movq -0x8(%rsp), %rdi
movq -0x10(%rsp), %rdx
movq -0x18(%rsp), %rsi
addl %r15d, %ecx
leaq 0x1(%r8), %r9
movl %r15d, (%rsi,%r8,4)
movl 0x8(%rdx), %r11d
cmpq $0xf9ff, %r8            # imm = 0xF9FF
setb %al
cmpl %r11d, %ecx
jae 0x6839
cmpq $0xf9ff, %r8            # imm = 0xF9FF
movq %r9, %r8
jb 0x663e
movl %r9d, %edx
movq -0x20(%rsp), %rsi
jmp 0x6847
movb $0x1, %al
xorl %edx, %edx
testb %al, %al
je 0x6856
movq 0x10(%rdi), %rax
movl $0x0, (%rax,%rdx,4)
movl %ecx, (%rsi)
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq