user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<img_rle_compact>:
  endbr64
  cmp    $0x1,%esi
  push   %r12
  mov    %rdx,%r9
  mov    %ecx,%edx
  sete   %al
  cmp    $0x1,%ecx
  push   %rbp
  sete   %cl
  push   %rbx
  test   %al,%al
  je     L60
  test   %cl,%cl
  je     L60
  movslq %r8d,%r8
  mov    %r9,%rdx
  add    %rdi,%r8
L179:
  cmp    %r8,%rdi
  jae    L41
  nopl   0x0(%rax,%rax,1)
L492:
  lea    0x2(%rdi),%rax
  cmp    %rax,%r8
  jbe    L641
  movzbl (%rdi),%ecx
  jmp    L341
  nopw   0x0(%rax,%rax,1)
L544:
  lea    0x1(%rax),%r11
  cmp    %r11,%r8
  je     L149
  mov    %r11,%rax
L341:
  mov    %ecx,%esi
  movzbl -0x1(%rax),%ecx
  cmp    %sil,%cl
  jne    L544
  cmp    (%rax),%cl
  jne    L544
  lea    -0x2(%rax),%rbx
  mov    %rax,%r11
  mov    %ebx,%r10d
  sub    %edi,%r10d
  nopl   0x0(%rax)
L450:
  test   %r10d,%r10d
  je     L62
L194:
  mov    $0x7e,%eax
  lea    0x1(%rdx),%r12
  cmp    %eax,%r10d
  cmovle %r10d,%eax
  movswl %ax,%ecx
  lea    -0x1(%rax),%esi
  sub    %ecx,%r10d
  mov    %eax,%ecx
  or     $0xffffff80,%ecx
  mov    %cl,(%rdx)
  test   %ax,%ax
  je     L151
  movzwl %si,%esi
  xor    %eax,%eax
  lea    0x1(%rsi),%rbp
  nop
L495:
  movzbl (%rdi,%rax,1),%ecx
  mov    %cl,0x1(%rdx,%rax,1)
  mov    %rax,%rcx
  add    $0x1,%rax
  cmp    %rcx,%rsi
  jne    L495
  add    %rbp,%rdi
  lea    (%r12,%rbp,1),%rdx
  test   %r10d,%r10d
  jne    L194
L62:
  lea    -0x1(%r11),%rdi
  movzbl -0x2(%r11),%r10d
  cmp    %rdi,%r8
  ja     L716
  jmp    L823
  nopl   0x0(%rax,%rax,1)
L402:
  add    $0x1,%rdi
  cmp    %rdi,%r8
  jbe    L823
L716:
  cmp    (%rdi),%r10b
  je     L402
  mov    %rdi,%rax
  sub    %rbx,%rax
  mov    %eax,%ecx
  test   %eax,%eax
  je     L179
  nopw   0x0(%rax,%rax,1)
L925:
  mov    $0x7e,%eax
  cmp    %eax,%ecx
  cmovle %ecx,%eax
  add    $0x2,%rdx
  mov    %al,-0x2(%rdx)
  movswl %ax,%esi
  mov    %r10b,-0x1(%rdx)
  sub    %esi,%ecx
  jne    L925
  cmp    %r8,%rdi
  jb     L492
L41:
  movb   $0x0,(%rdx)
  lea    0x1(%rdx),%rax
  sub    %r9d,%eax
L216:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L60:
  cmp    $0x2,%edx
  sete   %r10b
  test   %al,%al
  je     L400
  test   %r10b,%r10b
  je     L400
  movslq %r8d,%r8
  mov    %r9,%rdx
  add    %rdi,%r8
  cmp    %r8,%rdi
  jae    L618
L521:
  lea    0x2(%rdi),%rax
  cmp    %rax,%r8
  jbe    L424
  movzbl (%rdi),%ecx
  jmp    L347
L893:
  lea    0x1(%rax),%r11
  cmp    %r11,%r8
  je     L457
  mov    %r11,%rax
L347:
  mov    %ecx,%esi
  movzbl -0x1(%rax),%ecx
  cmp    %sil,%cl
  jne    L893
  cmp    (%rax),%cl
  jne    L893
  lea    -0x2(%rax),%rbx
  mov    %rax,%r11
  mov    %ebx,%r10d
  sub    %edi,%r10d
  nopl   0x0(%rax)
L937:
  test   %r10d,%r10d
  je     L227
L352:
  mov    $0x7e,%eax
  lea    0x2(%rdx),%r12
  cmp    %eax,%r10d
  cmovle %r10d,%eax
  movswl %ax,%ecx
  lea    -0x1(%rax),%esi
  sub    %ecx,%r10d
  mov    %eax,%ecx
  or     $0x80,%cl
  mov    %cx,(%rdx)
  test   %ax,%ax
  je     L131
  movzwl %si,%esi
  xor    %eax,%eax
  lea    0x1(%rsi),%rbp
  nopl   0x0(%rax,%rax,1)
L113:
  movzbl (%rdi,%rax,1),%ecx
  mov    %cx,0x2(%rdx,%rax,2)
  mov    %rax,%rcx
  add    $0x1,%rax
  cmp    %rcx,%rsi
  jne    L113
  add    %rbp,%rdi
  lea    (%r12,%rbp,2),%rdx
  test   %r10d,%r10d
  jne    L352
L227:
  lea    -0x1(%r11),%rdi
  movzbl -0x2(%r11),%eax
  cmp    %rdi,%r8
  ja     L863
  jmp    L146
  nopl   0x0(%rax)
L633:
  add    $0x1,%rdi
  cmp    %rdi,%r8
  jbe    L146
L863:
  cmp    (%rdi),%al
  je     L633
  mov    %rdi,%rsi
  sub    %rbx,%rsi
  mov    %esi,%ecx
  test   %esi,%esi
  je     L669
L764:
  movzbl %al,%r10d
  nopl   0x0(%rax)
L25:
  mov    $0x7e,%eax
  cmp    %eax,%ecx
  cmovle %ecx,%eax
  add    $0x4,%rdx
  mov    %ax,-0x4(%rdx)
  movswl %ax,%esi
  mov    %r10w,-0x2(%rdx)
  sub    %esi,%ecx
  jne    L25
L669:
  cmp    %rdi,%r8
  ja     L521
L618:
  xor    %ecx,%ecx
  lea    0x2(%rdx),%rax
  mov    %cx,(%rdx)
  sub    %r9,%rax
  sar    %rax
L154:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L400:
  cmp    $0x2,%esi
  sete   %al
  test   %cl,%cl
  je     L320
  test   %al,%al
  je     L320
  movslq %r8d,%r8
  mov    %r9,%rdx
  lea    (%rdi,%r8,2),%r10
  cmp    %r10,%rdi
  jae    L41
L515:
  lea    0x4(%rdi),%rax
  mov    %rdi,%rbx
  mov    %rax,%r11
  cmp    %rax,%r10
  ja     L250
  jmp    L288
  nopl   0x0(%rax,%rax,1)
L92:
  lea    0x2(%rax),%r11
  cmp    %r11,%r10
  jbe    L268
  mov    %r11,%rax
L250:
  movzwl -0x2(%rax),%ecx
  cmp    %cx,-0x4(%rax)
  jne    L92
  cmp    (%rax),%cx
  jne    L92
  lea    -0x4(%rax),%rbx
  mov    %rax,%r11
  mov    %rbx,%r8
  sub    %rdi,%r8
  sar    %r8
  nop
L562:
  test   %r8d,%r8d
  je     L288
L164:
  mov    $0x7e,%eax
  lea    0x1(%rdx),%r12
  cmp    %eax,%r8d
  cmovle %r8d,%eax
  movswl %ax,%ecx
  lea    -0x1(%rax),%esi
  sub    %ecx,%r8d
  mov    %eax,%ecx
  or     $0xffffff80,%ecx
  mov    %cl,(%rdx)
  test   %ax,%ax
  je     L139
  movzwl %si,%esi
  xor    %eax,%eax
  lea    0x1(%rsi),%rbp
  nopw   0x0(%rax,%rax,1)
L775:
  movzwl (%rdi,%rax,2),%ecx
  mov    %cl,0x1(%rdx,%rax,1)
  mov    %rax,%rcx
  add    $0x1,%rax
  cmp    %rcx,%rsi
  jne    L775
  lea    (%rdi,%rbp,2),%rdi
  lea    (%r12,%rbp,1),%rdx
  test   %r8d,%r8d
  jne    L164
L288:
  lea    -0x2(%r11),%rdi
  movzwl -0x4(%r11),%r8d
  cmp    %rdi,%r10
  jbe    L765
  movswl %r8w,%ecx
  jmp    L385
  nopl   0x0(%rax)
L274:
  add    $0x2,%rdi
  cmp    %rdi,%r10
  jbe    L765
L385:
  movzwl (%rdi),%eax
  cmp    %ecx,%eax
  je     L274
  mov    %rdi,%rax
  sub    %rbx,%rax
  sar    %rax
  mov    %eax,%ecx
  test   %eax,%eax
  je     L445
  nopl   0x0(%rax,%rax,1)
L527:
  mov    $0x7e,%eax
  cmp    %eax,%ecx
  cmovle %ecx,%eax
  add    $0x2,%rdx
  mov    %al,-0x2(%rdx)
  movswl %ax,%esi
  mov    %r8b,-0x1(%rdx)
  sub    %esi,%ecx
  jne    L527
L445:
  cmp    %rdi,%r10
  ja     L515
  jmp    L41
L320:
  test   %r10b,%r10b
  je     L585
  test   %al,%al
  je     L585
  movslq %r8d,%r8
  mov    %r9,%rcx
  lea    (%rdi,%r8,2),%r11
  cmp    %r11,%rdi
  jae    L510
L729:
  lea    0x4(%rdi),%rax
  mov    %rdi,%rbx
  mov    %rax,%r10
  cmp    %rax,%r11
  ja     L547
  jmp    L874
  nopw   0x0(%rax,%rax,1)
L896:
  lea    0x2(%rax),%r10
  cmp    %r10,%r11
  jbe    L259
  mov    %r10,%rax
L547:
  movzwl -0x2(%rax),%edx
  cmp    %dx,-0x4(%rax)
  jne    L896
  cmp    (%rax),%dx
  jne    L896
  lea    -0x4(%rax),%rbx
  mov    %rax,%r10
  mov    %rbx,%r8
  sub    %rdi,%r8
  sar    %r8
  nop
L211:
  test   %r8d,%r8d
  je     L874
L403:
  mov    $0x7e,%eax
  lea    0x2(%rcx),%rbp
  cmp    %eax,%r8d
  cmovle %r8d,%eax
  movswl %ax,%edx
  sub    %edx,%r8d
  mov    %eax,%edx
  or     $0x80,%dl
  mov    %dx,(%rcx)
  lea    -0x1(%rax),%edx
  test   %ax,%ax
  je     L703
  movzwl %dx,%edx
  xor    %eax,%eax
  lea    0x2(%rdx,%rdx,1),%rsi
  nopl   0x0(%rax)
L314:
  movzwl (%rdi,%rax,1),%edx
  mov    %dx,0x2(%rcx,%rax,1)
  add    $0x2,%rax
  cmp    %rax,%rsi
  jne    L314
  add    %rsi,%rdi
  lea    0x0(%rbp,%rsi,1),%rcx
  test   %r8d,%r8d
  jne    L403
L874:
  lea    -0x2(%r10),%rdi
  movzwl -0x4(%r10),%r8d
  cmp    %rdi,%r11
  jbe    L922
  movswl %r8w,%edx
  jmp    L931
  nopl   0x0(%rax,%rax,1)
L49:
  add    $0x2,%rdi
  cmp    %rdi,%r11
  jbe    L922
L931:
  movzwl (%rdi),%eax
  cmp    %edx,%eax
  je     L49
L922:
  mov    %rdi,%rax
  sub    %rbx,%rax
  sar    %rax
  mov    %eax,%edx
  test   %eax,%eax
  je     L278
  nopw   0x0(%rax,%rax,1)
L580:
  mov    $0x7e,%eax
  cmp    %eax,%edx
  cmovle %edx,%eax
  add    $0x4,%rcx
  mov    %ax,-0x4(%rcx)
  movswl %ax,%esi
  mov    %r8w,-0x2(%rcx)
  sub    %esi,%edx
  jne    L580
L278:
  cmp    %rdi,%r11
  ja     L729
L510:
  xor    %eax,%eax
  mov    %ax,(%rcx)
  lea    0x2(%rcx),%rax
  pop    %rbx
  sub    %r9,%rax
  pop    %rbp
  pop    %r12
  sar    %rax
  ret
  nopl   0x0(%rax,%rax,1)
L151:
  mov    %r12,%rdx
  jmp    L450
L149:
  lea    -0x1(%rax),%rbx
  mov    %ebx,%r10d
  sub    %edi,%r10d
  jmp    L450
L131:
  mov    %r12,%rdx
  jmp    L937
L823:
  mov    %rdi,%rax
  sub    %rbx,%rax
  mov    %eax,%ecx
  test   %eax,%eax
  jne    L925
  lea    0x1(%rdx),%rax
  movb   $0x0,(%rdx)
  sub    %r9d,%eax
  jmp    L216
L457:
  lea    -0x1(%rax),%rbx
  mov    %ebx,%r10d
  sub    %edi,%r10d
  jmp    L937
L146:
  mov    %rdi,%rsi
  sub    %rbx,%rsi
  mov    %esi,%ecx
  test   %esi,%esi
  jne    L764
  jmp    L618
L585:
  lea    D5(%rip),%rdi
  call   <i_errhdlr@plt>
  xor    %eax,%eax
  jmp    L154
  nopl   (%rax)
L703:
  mov    %rbp,%rcx
  jmp    L211
L259:
  lea    -0x2(%rax),%rbx
  mov    %rbx,%r8
  sub    %rdi,%r8
  sar    %r8
  jmp    L211
L139:
  mov    %r12,%rdx
  jmp    L562
L268:
  lea    -0x2(%rax),%rbx
  mov    %rbx,%r8
  sub    %rdi,%r8
  sar    %r8
  jmp    L562
L765:
  mov    %rdi,%rax
  sub    %rbx,%rax
  sar    %rax
  mov    %eax,%ecx
  test   %eax,%eax
  jne    L527
  jmp    L41
L641:
  mov    %rdi,%rbx
  mov    %rax,%r11
  jmp    L62
L424:
  mov    %rdi,%rbx
  mov    %rax,%r11
  jmp    L227
```

tool_calls: name: parse_data
arguments: data_label: D5
data_type: string

tool: D5: rle_compact: bad bpp: %d %d


assistant: ```c
int img_rle_compact(unsigned short *expbuf, int ibpp, unsigned short *rlebuf, int obpp, int cnt) {
  if (ibpp == 1 && obpp == 1) {
    register unsigned char *iptr = (unsigned char *)expbuf;
    register unsigned char *ibufend = iptr + cnt;
    register unsigned char *sptr;
    register unsigned char *optr = (unsigned char *)rlebuf;
    register short todo, cc;
    register int count;
    while (iptr < ibufend) {
      sptr = iptr;
      iptr += 2;
      while ((iptr < ibufend) && ((iptr[-2] != iptr[-1]) || (iptr[-1] != iptr[0])))
        iptr++;
      iptr -= 2;
      count = iptr - sptr;
      while (count) {
        todo = count > 126 ? 126 : count;
        count -= todo;
        *optr++ = 0x80 | todo;
        while (todo--)
          *optr++ = *sptr++;
      }
      sptr = iptr;
      cc = *iptr++;
      while ((iptr < ibufend) && (*iptr == cc))
        iptr++;
      count = iptr - sptr;
      while (count) {
        todo = count > 126 ? 126 : count;
        count -= todo;
        *optr++ = todo;
        *optr++ = cc;
      }
    }
    *optr++ = 0;
    ;
    return optr - (unsigned char *)rlebuf;
  } else if (ibpp == 1 && obpp == 2) {
    register unsigned char *iptr = (unsigned char *)expbuf;
    register unsigned char *ibufend = iptr + cnt;
    register unsigned char *sptr;
    register unsigned short *optr = rlebuf;
    register short todo, cc;
    register int count;
    while (iptr < ibufend) {
      sptr = iptr;
      iptr += 2;
      while ((iptr < ibufend) && ((iptr[-2] != iptr[-1]) || (iptr[-1] != iptr[0])))
        iptr++;
      iptr -= 2;
      count = iptr - sptr;
      while (count) {
        todo = count > 126 ? 126 : count;
        count -= todo;
        *optr++ = 0x80 | todo;
        while (todo--)
          *optr++ = *sptr++;
      }
      sptr = iptr;
      cc = *iptr++;
      while ((iptr < ibufend) && (*iptr == cc))
        iptr++;
      count = iptr - sptr;
      while (count) {
        todo = count > 126 ? 126 : count;
        count -= todo;
        *optr++ = todo;
        *optr++ = cc;
      }
    }
    *optr++ = 0;
    ;
    return optr - rlebuf;
  } else if (ibpp == 2 && obpp == 1) {
    register unsigned short *iptr = expbuf;
    register unsigned short *ibufend = iptr + cnt;
    register unsigned short *sptr;
    register unsigned char *optr = (unsigned char *)rlebuf;
    register short todo, cc;
    register int count;
    while (iptr < ibufend) {
      sptr = iptr;
      iptr += 2;
      while ((iptr < ibufend) && ((iptr[-2] != iptr[-1]) || (iptr[-1] != iptr[0])))
        iptr++;
      iptr -= 2;
      count = iptr - sptr;
      while (count) {
        todo = count > 126 ? 126 : count;
        count -= todo;
        *optr++ = 0x80 | todo;
        while (todo--)
          *optr++ = *sptr++;
      }
      sptr = iptr;
      cc = *iptr++;
      while ((iptr < ibufend) && (*iptr == cc))
        iptr++;
      count = iptr - sptr;
      while (count) {
        todo = count > 126 ? 126 : count;
        count -= todo;
        *optr++ = todo;
        *optr++ = cc;
      }
    }
    *optr++ = 0;
    ;
    return optr - (unsigned char *)rlebuf;
  } else if (ibpp == 2 && obpp == 2) {
    register unsigned short *iptr = expbuf;
    register unsigned short *ibufend = iptr + cnt;
    register unsigned short *sptr;
    register unsigned short *optr = rlebuf;
    register short todo, cc;
    register int count;
    while (iptr < ibufend) {
      sptr = iptr;
      iptr += 2;
      while ((iptr < ibufend) && ((iptr[-2] != iptr[-1]) || (iptr[-1] != iptr[0])))
        iptr++;
      iptr -= 2;
      count = iptr - sptr;
      while (count) {
        todo = count > 126 ? 126 : count;
        count -= todo;
        *optr++ = 0x80 | todo;
        while (todo--)
          *optr++ = *sptr++;
      }
      sptr = iptr;
      cc = *iptr++;
      while ((iptr < ibufend) && (*iptr == cc))
        iptr++;
      count = iptr - sptr;
      while (count) {
        todo = count > 126 ? 126 : count;
        count -= todo;
        *optr++ = todo;
        *optr++ = cc;
      }
    }
    *optr++ = 0;
    ;
    return optr - rlebuf;
  } else {
    i_errhdlr("rle_compact: bad bpp: %d %d\n", ibpp, obpp);
    return 0;
  }
}
```