user: Please show me the C implementation that matches the assembly code listed below:

```asm
<putsprite_blend_flip_>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,0x18(%rsp)
  mov    %esi,0x3c(%rsp)
  mov    %rdx,0x20(%rsp)
  mov    %r9d,0xc(%rsp)
  test   %r8d,%r8d
  jle    L15
  movslq %r9d,%rax
  movslq %r8d,%r8
  mov    %rcx,%rbp
  shl    $0x2,%rax
  mov    %rax,0x28(%rsp)
  lea    (%rdx,%r8,4),%rax
  mov    %rax,0x30(%rsp)
  nopl   0x0(%rax)
L4:
  mov    0x20(%rsp),%rax
  mov    0x3c(%rsp),%r15d
  movslq (%rax),%r9
  lea    (%rax,%r9,1),%r14
  add    $0x4,%rax
  mov    %rax,0x20(%rsp)
  nopw   0x0(%rax,%rax,1)
L51:
  test   %r15d,%r15d
  jle    L30
L14:
  movzbl (%r14),%eax
  cmp    $0xff,%eax
  je     L30
  sub    %eax,%r15d
  test   %r15d,%r15d
  jle    L30
  movzbl 0x1(%r14),%r13d
  add    $0x2,%r14
  test   %r13d,%r13d
  je     L51
  mov    %r15d,%esi
  sub    %r13d,%esi
  cmp    0xc(%rsp),%esi
  jl     L83
  mov    %esi,%r15d
  add    %r13,%r14
  test   %r15d,%r15d
  jg     L14
  nopl   (%rax)
L30:
  mov    0x28(%rsp),%rcx
  add    %rcx,0x18(%rsp)
  mov    0x30(%rsp),%rcx
  cmp    %rcx,0x20(%rsp)
  jne    L4
L15:
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L83:
  mov    0xc(%rsp),%eax
  cmp    %eax,%r15d
  jle    L97
  sub    %eax,%r15d
  sub    %r15d,%r13d
  movslq %r15d,%r15
  add    %r15,%r14
  cmp    %eax,%r13d
  mov    %eax,%r15d
  cmovg  %eax,%r13d
  test   %r13d,%r13d
  jle    L51
L103:
  mov    0x18(%rsp),%rcx
  movslq %r15d,%rax
  mov    %r14,0x10(%rsp)
  mov    0x80(%rsp),%rbx
  mov    %r13d,0x38(%rsp)
  lea    (%rcx,%rax,4),%r12
  lea    0x0(%r13,%r14,1),%eax
  mov    %r14,%r13
  mov    %r12,%r14
  mov    %eax,%r12d
L44:
  movzbl 0x0(%r13),%eax
  mov    -0x4(%r14),%esi
  add    $0x1,%r13
  sub    $0x4,%r14
  mov    0x0(%rbp,%rax,4),%edi
  call   *%rbx
  mov    %eax,(%r14)
  mov    %r12d,%eax
  sub    %r13d,%eax
  test   %eax,%eax
  jg     L44
  mov    0x38(%rsp),%r13d
  mov    $0x1,%eax
  mov    $0x1,%ecx
  mov    0x10(%rsp),%r14
  test   %r13d,%r13d
  cmovg  %r13d,%eax
  sub    %eax,%r15d
  lea    -0x1(%r13),%eax
  add    $0x1,%rax
  test   %r13d,%r13d
  cmovle %rcx,%rax
  add    %rax,%r14
  jmp    L51
  nopl   0x0(%rax)
L97:
  test   %esi,%esi
  cmovs  %r15d,%r13d
  jmp    L103
```

assistant: ```c
void putsprite_blend_flip_(unsigned *dest, int x, int *linetab, unsigned *palette, int h, int screenwidth, unsigned (*blendfp)(unsigned, unsigned)) {
  for (; h > 0; h--, dest += screenwidth) {
    register int lx = x;
    unsigned char *data = ((unsigned char *)linetab) + (*linetab);
    linetab++;
    while (lx > 0) {
      register int count = *data++;
      if (count == 0xFF)
        break;
      lx -= count;
      if (lx <= 0)
        break;
      count = *data++;
      if (!count)
        continue;
      if ((lx - count) >= screenwidth) {
        lx -= count;
        data += count;
        continue;
      }
      if (lx > screenwidth) {
        int diff = (lx - screenwidth);
        count -= diff;
        data += diff;
        lx = screenwidth;
      }
      if ((lx - count) < 0) {
        count = lx;
      }
      for (; count > 0; count--) {
        --lx;
        dest[lx] = blendfp(palette[*data++], dest[lx]);
      }
    }
  }
}
```