// File: /workspace/github_cpp_makefile_star2_O2/sbingner[P]kerneldec/lzfse/src/lzvn_encode_base.c
// Function: lzvn_emit_match
static inline lzvn_offset lzvn_emit_match(lzvn_encoder_state *state,
                                          lzvn_match_info match) {
  size_t L = (size_t)(match.m_begin - state->src_literal); // literal count
  size_t M = (size_t)match.M;                              // match length
  size_t D = (size_t)match.D;                              // match distance
  size_t D_prev = (size_t)state->d_prev; // previously emitted match distance
  unsigned char *dst = emit(state->src + state->src_literal, state->dst,
                            state->dst_end, L, M, D, D_prev);
  // Check if DST is full
  if (dst >= state->dst_end) {
    return 0; // FULL
  }

  // Update state
  lzvn_offset dst_used = dst - state->dst;
  state->d_prev = match.D;
  state->dst = dst;
  state->src_literal = match.m_end;
  return dst_used;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x50(%rsp), %rcx
movq (%rcx), %r14
movq 0x10(%rcx), %rax
movq %rax, (%rsp)
movq 0x28(%rdi), %r15
movq 0x30(%rdi), %rax
subq %r15, %r14
movq 0x18(%rcx), %rcx
movq %rcx, 0x10(%rsp)
movq 0x70(%rdi), %rcx
movq %rcx, 0x8(%rsp)
addq (%rdi), %r15
movq 0x40(%rdi), %rbp
movl $0x10f, %r13d           # imm = 0x10F
cmpq $0x10, %r14
jb 0x67c1
cmpq %r13, %r14
movl $0x10f, %r12d           # imm = 0x10F
cmovbq %r14, %r12
leaq (%rax,%r12), %rcx
addq $0xa, %rcx
cmpq %rbp, %rcx
jae 0x6935
movl %r12d, %ecx
shll $0x8, %ecx
addl $0xfffff0e0, %ecx       # imm = 0xFFFFF0E0
movw %cx, (%rax)
addq $0x2, %rax
subq %r12, %r14
movq %rax, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x6b77
addq %r12, %r15
jmp 0x6774
cmpq $0x4, %r14
jb 0x67fd
leaq (%rax,%r14), %rcx
addq $0xa, %rcx
cmpq %rbp, %rcx
movq (%rsp), %r12
jae 0x6935
movl %r14d, %ecx
orb $-0x20, %cl
movb %cl, (%rax)
incq %rax
movq %rax, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x6b77
addq %r14, %r15
xorl %r14d, %r14d
jmp 0x6801
movq (%rsp), %r12
pushq $0xa
popq %rdi
subq %r14, %rdi
subq %r14, %rdi
cmpq %r12, %rdi
cmovaeq %r12, %rdi
leaq 0x8(%rax), %rcx
cmpq %rbp, %rcx
jae 0x6935
movq %r12, %rcx
subq %rdi, %rcx
leaq -0x3(%rdi), %rsi
movl (%r15), %edx
movq 0x10(%rsp), %r9
cmpq 0x8(%rsp), %r9
jne 0x6861
movl %r14d, %r8d
shll $0x6, %r8d
testq %r14, %r14
leal (%r8,%rsi,8), %esi
movl $0xf0, %r8d
pushq $0x6
popq %r9
cmovel %r8d, %r9d
cmovnel %esi, %edi
orl %r9d, %edi
movb %dil, (%rax)
incq %rax
jmp 0x68df
cmpq $0x5ff, %r9             # imm = 0x5FF
ja 0x688b
movl %r9d, %edi
shrl $0x8, %edi
movl %r14d, %r8d
shll $0x6, %r8d
orl %edi, %r8d
leal (%r8,%rsi,8), %esi
movb %sil, (%rax)
movb %r9b, 0x1(%rax)
addq $0x2, %rax
jmp 0x68df
cmpq $0x22, %r12
ja 0x68c6
cmpq $0x3fff, %r9            # imm = 0x3FFF
ja 0x68c6
testq %rcx, %rcx
je 0x68c6
addl $-0x3, %r12d
movl %r12d, %ecx
shrl $0x2, %ecx
leal (%rcx,%r14,8), %ecx
addb $-0x60, %cl
movb %cl, (%rax)
andl $0x3, %r12d
leal (%r12,%r9,4), %ecx
movw %cx, 0x1(%rax)
addq $0x3, %rax
xorl %ecx, %ecx
jmp 0x68df
movl %r14d, %edi
shll $0x6, %edi
leal (%rdi,%rsi,8), %esi
orb $0x7, %sil
movb %sil, (%rax)
movw %r9w, 0x1(%rax)
addq $0x3, %rax
movl %edx, (%rax)
addq %rax, %r14
movl $0x10f, %eax            # imm = 0x10F
cmpq $0x10, %rcx
jb 0x6919
leaq 0x2(%r14), %rdx
cmpq %rbp, %rdx
jae 0x6935
cmpq %rax, %rcx
movl $0x10f, %esi            # imm = 0x10F
cmovbq %rcx, %rsi
subq %rsi, %rcx
shll $0x8, %esi
addl $0xfffff0f0, %esi       # imm = 0xFFFFF0F0
movw %si, (%r14)
movq %rdx, %r14
jmp 0x68e9
testq %rcx, %rcx
je 0x6932
leaq 0x1(%r14), %rax
cmpq %rbp, %rax
jae 0x6935
orb $-0x10, %cl
movb %cl, (%r14)
movq %rax, %rbp
jmp 0x6935
movq %r14, %rbp
cmpq 0x40(%rbx), %rbp
jae 0x695d
movq %rbp, %rax
subq 0x30(%rbx), %rax
leaq 0x50(%rsp), %rdx
movq 0x18(%rdx), %rcx
movq %rcx, 0x70(%rbx)
movq %rbp, 0x30(%rbx)
movq 0x8(%rdx), %rcx
movq %rcx, 0x28(%rbx)
jmp 0x695f
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq