user: 请将以下的汇编代码转换成C语言代码：

```asm
<img_rle_compact>:
  endbr64
  push   %rbp
  mov    %rdx,%r9
  mov    %ecx,%edx
  push   %rbx
  sub    $0x8,%rsp
  cmp    $0x1,%esi
  sete   %al
  cmp    $0x1,%ecx
  sete   %cl
  test   %al,%al
  je     L77
  test   %cl,%cl
  je     L77
  movslq %r8d,%r8
  mov    %r9,%rdx
  lea    (%rdi,%r8,1),%r10
L761:
  cmp    %r10,%rdi
  jae    L792
  xchg   %ax,%ax
L646:
  lea    0x2(%rdi),%rax
  cmp    %rax,%r10
  jbe    L159
  movzbl (%rdi),%ecx
  jmp    L930
  nopw   0x0(%rax,%rax,1)
L516:
  lea    0x1(%rax),%r11
  cmp    %r11,%r10
  je     L242
  mov    %r11,%rax
L930:
  mov    %ecx,%esi
  movzbl -0x1(%rax),%ecx
  cmp    %sil,%cl
  jne    L516
  cmp    (%rax),%cl
  jne    L516
  lea    -0x2(%rax),%rbx
  mov    %rax,%r11
  mov    %ebx,%r8d
  sub    %edi,%r8d
  nopl   0x0(%rax)
L319:
  test   %r8d,%r8d
  je     L825
L490:
  mov    $0x7e,%ecx
  lea    0x1(%rdx),%rbp
  cmp    %ecx,%r8d
  cmovle %r8d,%ecx
  movzwl %cx,%eax
  sub    %eax,%r8d
  mov    %ecx,%eax
  or     $0xffffff80,%eax
  mov    %al,(%rdx)
  test   %cx,%cx
  je     L443
  movzwl %cx,%ecx
  xor    %eax,%eax
  nopl   0x0(%rax,%rax,1)
L944:
  movzbl (%rdi,%rax,1),%esi
  mov    %sil,0x1(%rdx,%rax,1)
  add    $0x1,%rax
  cmp    %rax,%rcx
  jne    L944
  add    %rcx,%rdi
  lea    0x0(%rbp,%rcx,1),%rdx
  test   %r8d,%r8d
  jne    L490
L825:
  lea    -0x1(%r11),%rdi
  movzbl -0x2(%r11),%r8d
  cmp    %rdi,%r10
  ja     L237
  jmp    L567
  nopw   0x0(%rax,%rax,1)
L108:
  add    $0x1,%rdi
  cmp    %rdi,%r10
  jbe    L567
L237:
  cmp    (%rdi),%r8b
  je     L108
  mov    %rdi,%rax
  sub    %rbx,%rax
  mov    %eax,%ecx
  test   %eax,%eax
  je     L761
  nopw   0x0(%rax,%rax,1)
L105:
  mov    $0x7e,%eax
  cmp    %eax,%ecx
  cmovle %ecx,%eax
  add    $0x2,%rdx
  mov    %al,-0x2(%rdx)
  movzwl %ax,%esi
  mov    %r8b,-0x1(%rdx)
  sub    %esi,%ecx
  jne    L105
  cmp    %r10,%rdi
  jb     L646
L792:
  movb   $0x0,(%rdx)
  lea    0x1(%rdx),%rax
  sub    %r9d,%eax
L817:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L77:
  cmp    $0x2,%edx
  sete   %r10b
  test   %al,%al
  je     L893
  test   %r10b,%r10b
  je     L893
  movslq %r8d,%r8
  mov    %r9,%rdx
  lea    (%rdi,%r8,1),%r10
L76:
  cmp    %r10,%rdi
  jae    L167
L579:
  lea    0x2(%rdi),%rax
  cmp    %rax,%r10
  jbe    L6
  movzbl (%rdi),%ecx
  jmp    L755
  nopl   0x0(%rax,%rax,1)
L834:
  lea    0x1(%rax),%r11
  cmp    %r11,%r10
  je     L569
  mov    %r11,%rax
L755:
  mov    %ecx,%esi
  movzbl -0x1(%rax),%ecx
  cmp    %sil,%cl
  jne    L834
  cmp    (%rax),%cl
  jne    L834
  lea    -0x2(%rax),%rbp
  mov    %rax,%r11
  mov    %ebp,%r8d
  sub    %edi,%r8d
  nopl   0x0(%rax)
L566:
  test   %r8d,%r8d
  je     L111
L224:
  mov    $0x7e,%ecx
  lea    0x2(%rdx),%rbx
  cmp    %ecx,%r8d
  cmovle %r8d,%ecx
  movzwl %cx,%eax
  sub    %eax,%r8d
  mov    %ecx,%eax
  or     $0x80,%al
  mov    %ax,(%rdx)
  test   %cx,%cx
  je     L219
  movzwl %cx,%ecx
  xor    %eax,%eax
  nopl   0x0(%rax,%rax,1)
L121:
  movzbl (%rdi,%rax,1),%esi
  mov    %si,0x2(%rdx,%rax,2)
  add    $0x1,%rax
  cmp    %rax,%rcx
  jne    L121
  add    %rcx,%rdi
  lea    (%rbx,%rcx,2),%rdx
  test   %r8d,%r8d
  jne    L224
L111:
  movzbl -0x2(%r11),%r8d
  lea    -0x1(%r11),%rdi
  mov    %r8d,%eax
  cmp    %rdi,%r10
  ja     L1
  jmp    L373
  nopl   0x0(%rax)
L254:
  add    $0x1,%rdi
  cmp    %rdi,%r10
  jbe    L373
L1:
  cmp    (%rdi),%al
  je     L254
  mov    %rdi,%rax
  sub    %rbp,%rax
  mov    %eax,%ecx
  test   %eax,%eax
  je     L76
  nopl   0x0(%rax)
L519:
  mov    $0x7e,%eax
  cmp    %eax,%ecx
  cmovle %ecx,%eax
  add    $0x4,%rdx
  mov    %ax,-0x4(%rdx)
  movzwl %ax,%esi
  mov    %r8w,-0x2(%rdx)
  sub    %esi,%ecx
  jne    L519
  cmp    %r10,%rdi
  jb     L579
L167:
  xor    %eax,%eax
  mov    %ax,(%rdx)
  lea    0x2(%rdx),%rax
  sub    %r9,%rax
  sar    %rax
L873:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L893:
  cmp    $0x2,%esi
  sete   %al
  test   %cl,%cl
  je     L586
  test   %al,%al
  je     L586
  movslq %r8d,%r8
  mov    %r9,%rsi
  lea    (%rdi,%r8,2),%r11
  cmp    %r11,%rdi
  jae    L725
L131:
  lea    0x4(%rdi),%rax
  mov    %rdi,%rbp
  mov    %rax,%r10
  cmp    %rax,%r11
  ja     L664
  jmp    L196
  nopw   0x0(%rax,%rax,1)
L491:
  lea    0x2(%rax),%r10
  cmp    %r10,%r11
  jbe    L321
  mov    %r10,%rax
L664:
  movzwl -0x2(%rax),%edx
  cmp    %dx,-0x4(%rax)
  jne    L491
  cmp    (%rax),%dx
  jne    L491
  lea    -0x4(%rax),%rbp
  mov    %rax,%r10
  mov    %rbp,%r8
  sub    %rdi,%r8
  sar    %r8
  nop
L238:
  test   %r8d,%r8d
  je     L196
L286:
  mov    $0x7e,%edx
  lea    0x1(%rsi),%rbx
  cmp    %edx,%r8d
  cmovle %r8d,%edx
  movzwl %dx,%eax
  sub    %eax,%r8d
  mov    %edx,%eax
  or     $0xffffff80,%eax
  mov    %al,(%rsi)
  test   %dx,%dx
  je     L329
  movzwl %dx,%edx
  xor    %eax,%eax
L2:
  movzwl (%rdi,%rax,2),%ecx
  mov    %cl,0x1(%rsi,%rax,1)
  add    $0x1,%rax
  cmp    %rax,%rdx
  jne    L2
  lea    (%rdi,%rdx,2),%rdi
  lea    (%rbx,%rdx,1),%rsi
  test   %r8d,%r8d
  jne    L286
L196:
  lea    -0x2(%r10),%rdi
  movzwl -0x4(%r10),%eax
  cmp    %rdi,%r11
  ja     L659
  jmp    L13
  nopl   0x0(%rax)
L368:
  add    $0x2,%rdi
  cmp    %rdi,%r11
  jbe    L13
L659:
  cmp    %ax,(%rdi)
  je     L368
  mov    %rdi,%rcx
  sub    %rbp,%rcx
  sar    %rcx
  mov    %ecx,%edx
  test   %ecx,%ecx
  je     L353
L783:
  mov    %eax,%r8d
  nopl   0x0(%rax)
L182:
  mov    $0x7e,%eax
  cmp    %eax,%edx
  cmovle %edx,%eax
  add    $0x2,%rsi
  mov    %al,-0x2(%rsi)
  movzwl %ax,%ecx
  mov    %r8b,-0x1(%rsi)
  sub    %ecx,%edx
  jne    L182
L353:
  cmp    %rdi,%r11
  ja     L131
L725:
  movb   $0x0,(%rsi)
  lea    0x1(%rsi),%rax
  add    $0x8,%rsp
  sub    %r9d,%eax
  pop    %rbx
  pop    %rbp
  ret
L586:
  test   %r10b,%r10b
  je     L878
  test   %al,%al
  je     L878
  movslq %r8d,%r8
  mov    %r9,%rdx
  lea    (%rdi,%r8,2),%r10
L526:
  cmp    %r10,%rdi
  jae    L167
  lea    0x4(%rdi),%rax
  mov    %rdi,%rbx
  mov    %rax,%r11
  cmp    %rax,%r10
  ja     L712
  jmp    L407
  xchg   %ax,%ax
L303:
  lea    0x2(%rax),%r11
  cmp    %r11,%r10
  jbe    L354
  mov    %r11,%rax
L712:
  movzwl -0x2(%rax),%ecx
  cmp    %cx,-0x4(%rax)
  jne    L303
  cmp    (%rax),%cx
  jne    L303
  lea    -0x4(%rax),%rbx
  mov    %rax,%r11
  mov    %rbx,%r8
  sub    %rdi,%r8
  sar    %r8
  nop
L147:
  test   %r8d,%r8d
  je     L407
L480:
  mov    $0x7e,%ecx
  lea    0x2(%rdx),%rbp
  cmp    %ecx,%r8d
  cmovle %r8d,%ecx
  movzwl %cx,%eax
  sub    %eax,%r8d
  mov    %ecx,%eax
  or     $0x80,%al
  mov    %ax,(%rdx)
  test   %cx,%cx
  je     L171
  movzwl %cx,%ecx
  xor    %eax,%eax
  add    %rcx,%rcx
  nopl   0x0(%rax,%rax,1)
L672:
  movzwl (%rdi,%rax,1),%esi
  mov    %si,0x2(%rdx,%rax,1)
  add    $0x2,%rax
  cmp    %rax,%rcx
  jne    L672
  add    %rcx,%rdi
  lea    0x0(%rbp,%rcx,1),%rdx
  test   %r8d,%r8d
  jne    L480
L407:
  lea    -0x2(%r11),%rdi
  movzwl -0x4(%r11),%r8d
  cmp    %rdi,%r10
  ja     L239
  jmp    L529
  nopw   0x0(%rax,%rax,1)
L578:
  add    $0x2,%rdi
  cmp    %rdi,%r10
  jbe    L529
L239:
  cmp    %r8w,(%rdi)
  je     L578
  mov    %rdi,%rax
  sub    %rbx,%rax
  sar    %rax
  mov    %eax,%ecx
  test   %eax,%eax
  je     L526
  cs nopw 0x0(%rax,%rax,1)
L700:
  mov    $0x7e,%eax
  cmp    %eax,%ecx
  cmovle %ecx,%eax
  add    $0x4,%rdx
  mov    %ax,-0x4(%rdx)
  movzwl %ax,%esi
  mov    %r8w,-0x2(%rdx)
  sub    %esi,%ecx
  jne    L700
  jmp    L526
  nopl   0x0(%rax,%rax,1)
L443:
  mov    %rbp,%rdx
  jmp    L319
L242:
  lea    -0x1(%rax),%rbx
  mov    %ebx,%r8d
  sub    %edi,%r8d
  jmp    L319
L219:
  mov    %rbx,%rdx
  jmp    L566
L567:
  mov    %rdi,%rax
  sub    %rbx,%rax
  mov    %eax,%ecx
  test   %eax,%eax
  jne    L105
  jmp    L792
L569:
  lea    -0x1(%rax),%rbp
  mov    %ebp,%r8d
  sub    %edi,%r8d
  jmp    L566
L373:
  mov    %rdi,%rax
  sub    %rbp,%rax
  mov    %eax,%ecx
  test   %eax,%eax
  jne    L519
  xor    %eax,%eax
  mov    %ax,(%rdx)
  lea    0x2(%rdx),%rax
  sub    %r9,%rax
  sar    %rax
  jmp    L873
L878:
  lea    D8(%rip),%rdi
  call   <i_errhdlr@plt>
  xor    %eax,%eax
  jmp    L817
  nopw   0x0(%rax,%rax,1)
L171:
  mov    %rbp,%rdx
  jmp    L147
L354:
  lea    -0x2(%rax),%rbx
  mov    %rbx,%r8
  sub    %rdi,%r8
  sar    %r8
  jmp    L147
L329:
  mov    %rbx,%rsi
  jmp    L238
L321:
  lea    -0x2(%rax),%rbp
  mov    %rbp,%r8
  sub    %rdi,%r8
  sar    %r8
  jmp    L238
L529:
  mov    %rdi,%rax
  sub    %rbx,%rax
  sar    %rax
  mov    %eax,%ecx
  test   %eax,%eax
  jne    L700
  jmp    L167
L13:
  mov    %rdi,%rcx
  sub    %rbp,%rcx
  sar    %rcx
  mov    %ecx,%edx
  test   %ecx,%ecx
  jne    L783
  jmp    L725
L159:
  mov    %rdi,%rbx
  mov    %rax,%r11
  jmp    L825
L6:
  mov    %rdi,%rbp
  mov    %rax,%r11
  jmp    L111
```

tool_calls: name: disassemble_data
arguments: tag: D8
type_guessed: string

tool: D8: 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 unsigned 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 unsigned 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 unsigned 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 unsigned 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;
  }
}
```