user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<img_rle_compact>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdx,%r9
  mov    %ecx,%edx
  cmp    $0x1,%esi
  sete   %al
  cmp    $0x1,%ecx
  sete   %cl
  test   %al,%al
  je     L831
  test   %cl,%cl
  je     L831
  movslq %r8d,%r8
  lea    (%rdi,%r8,1),%r10
  cmp    %r10,%rdi
  jae    L832
  mov    %r9,%rdx
  jmp    L905
L511:
  add    $0x1,%r8
  cmp    %r8,%r10
  je     L46
L151:
  movzbl -0x1(%r8),%eax
  cmp    %al,-0x2(%r8)
  jne    L511
  cmp    (%r8),%al
  jne    L511
  jmp    L262
L46:
  mov    %r10,%r8
L262:
  lea    -0x2(%r8),%rbp
  mov    %rbp,%rax
  sub    %rdi,%rax
  mov    %eax,%r11d
  test   %eax,%eax
  je     L755
L13:
  mov    $0x7e,%eax
  cmp    %eax,%r11d
  cmovle %r11d,%eax
  movzwl %ax,%ecx
  sub    %ecx,%r11d
  lea    0x1(%rdx),%r12
  mov    %eax,%ecx
  or     $0xffffff80,%ecx
  mov    %cl,(%rdx)
  lea    -0x1(%rax),%esi
  test   %ax,%ax
  je     L664
  movzwl %si,%esi
  lea    0x1(%rsi),%rbx
  mov    $0x0,%eax
L242:
  movzbl (%rdi,%rax,1),%ecx
  mov    %cl,0x1(%rdx,%rax,1)
  mov    %rax,%rcx
  add    $0x1,%rax
  cmp    %rcx,%rsi
  jne    L242
  add    %rbx,%rdi
  lea    (%r12,%rbx,1),%rdx
L466:
  test   %r11d,%r11d
  jne    L13
L755:
  lea    -0x1(%r8),%rdi
  movzbl -0x2(%r8),%r8d
  cmp    %rdi,%r10
  jbe    L506
L717:
  cmp    (%rdi),%r8b
  jne    L454
  add    $0x1,%rdi
  cmp    %rdi,%r10
  ja     L717
L506:
  mov    %rdi,%rax
  sub    %rbp,%rax
  mov    %eax,%ecx
  test   %eax,%eax
  je     L840
L138:
  mov    $0x7e,%eax
  cmp    %eax,%ecx
  cmovle %ecx,%eax
  movzwl %ax,%esi
  mov    %al,(%rdx)
  add    $0x2,%rdx
  mov    %r8b,-0x1(%rdx)
  sub    %esi,%ecx
  jne    L138
L148:
  cmp    %r10,%rdi
  jae    L840
L905:
  lea    0x2(%rdi),%r8
  cmp    %r8,%r10
  ja     L151
  jmp    L262
L664:
  mov    %r12,%rdx
  jmp    L466
L454:
  mov    %rdi,%rax
  sub    %rbp,%rax
  mov    %eax,%ecx
  test   %eax,%eax
  jne    L138
  jmp    L148
L832:
  mov    %r9,%rdx
L840:
  movb   $0x0,(%rdx)
  lea    0x1(%rdx),%rax
  sub    %r9d,%eax
L404:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L831:
  cmp    $0x2,%edx
  sete   %r10b
  test   %al,%al
  je     L545
  test   %r10b,%r10b
  je     L545
  movslq %r8d,%r8
  lea    (%rdi,%r8,1),%r11
  cmp    %r11,%rdi
  jae    L845
  mov    %r9,%rdx
  jmp    L312
L275:
  add    $0x1,%r8
  cmp    %r8,%r11
  je     L747
L11:
  movzbl -0x1(%r8),%eax
  cmp    %al,-0x2(%r8)
  jne    L275
  cmp    (%r8),%al
  jne    L275
  jmp    L750
L747:
  mov    %r11,%r8
L750:
  lea    -0x2(%r8),%rbp
  mov    %rbp,%rax
  sub    %rdi,%rax
  mov    %eax,%r10d
  test   %eax,%eax
  je     L369
L372:
  mov    $0x7e,%eax
  cmp    %eax,%r10d
  cmovle %r10d,%eax
  movzwl %ax,%ecx
  sub    %ecx,%r10d
  lea    0x2(%rdx),%r12
  mov    %eax,%ecx
  or     $0x80,%cl
  mov    %cx,(%rdx)
  lea    -0x1(%rax),%esi
  test   %ax,%ax
  je     L271
  movzwl %si,%esi
  lea    0x1(%rsi),%rbx
  mov    $0x0,%eax
L871:
  movzbl (%rdi,%rax,1),%ecx
  mov    %cx,0x2(%rdx,%rax,2)
  mov    %rax,%rcx
  add    $0x1,%rax
  cmp    %rsi,%rcx
  jne    L871
  add    %rbx,%rdi
  lea    (%r12,%rbx,2),%rdx
L368:
  test   %r10d,%r10d
  jne    L372
L369:
  lea    -0x1(%r8),%rdi
  movzbl -0x2(%r8),%eax
  movzbl %al,%r8d
  cmp    %rdi,%r11
  jbe    L102
L858:
  cmp    (%rdi),%al
  jne    L903
  add    $0x1,%rdi
  cmp    %rdi,%r11
  ja     L858
L102:
  mov    %rdi,%rax
  sub    %rbp,%rax
  mov    %eax,%ecx
  test   %eax,%eax
  je     L396
L791:
  mov    $0x7e,%eax
  cmp    %eax,%ecx
  cmovle %ecx,%eax
  movzwl %ax,%esi
  mov    %ax,(%rdx)
  add    $0x4,%rdx
  mov    %r8w,-0x2(%rdx)
  sub    %esi,%ecx
  jne    L791
L867:
  cmp    %r11,%rdi
  jae    L396
L312:
  lea    0x2(%rdi),%r8
  cmp    %r8,%r11
  ja     L11
  jmp    L750
L271:
  mov    %r12,%rdx
  jmp    L368
L903:
  mov    %rdi,%rax
  sub    %rbp,%rax
  mov    %eax,%ecx
  test   %eax,%eax
  jne    L791
  jmp    L867
L845:
  mov    %r9,%rdx
L396:
  movw   $0x0,(%rdx)
  lea    0x2(%rdx),%rax
  sub    %r9,%rax
  sar    %rax
  jmp    L404
L545:
  cmp    $0x2,%esi
  sete   %al
  test   %cl,%cl
  je     L576
  test   %al,%al
  je     L576
  movslq %r8d,%r8
  lea    (%rdi,%r8,2),%r10
  cmp    %r10,%rdi
  jae    L176
  mov    %r9,%rdx
  jmp    L156
L463:
  add    $0x2,%r8
  cmp    %r8,%r10
  jbe    L303
L563:
  movzwl -0x2(%r8),%eax
  cmp    %ax,-0x4(%r8)
  jne    L463
  cmp    (%r8),%ax
  jne    L463
L303:
  lea    -0x4(%r8),%rbp
  mov    %rbp,%rax
  sub    %rdi,%rax
  sar    %rax
  mov    %eax,%r11d
  test   %eax,%eax
  jne    L223
L776:
  lea    -0x2(%r8),%rdi
  movzwl -0x4(%r8),%r8d
  cmp    %rdi,%r10
  jbe    L889
L86:
  cmp    %r8w,(%rdi)
  jne    L889
  add    $0x2,%rdi
  cmp    %rdi,%r10
  ja     L86
L889:
  mov    %rdi,%rax
  sub    %rbp,%rax
  sar    %rax
  mov    %eax,%ecx
  test   %eax,%eax
  je     L809
L672:
  mov    $0x7e,%eax
  cmp    %eax,%ecx
  cmovle %ecx,%eax
  movzwl %ax,%esi
  mov    %al,(%rdx)
  add    $0x2,%rdx
  mov    %r8b,-0x1(%rdx)
  sub    %esi,%ecx
  jne    L672
L809:
  cmp    %rdi,%r10
  jbe    L451
L156:
  lea    0x4(%rdi),%r8
  cmp    %r8,%r10
  ja     L563
  jmp    L303
L106:
  mov    %r12,%rdx
L315:
  test   %r11d,%r11d
  je     L776
L223:
  mov    $0x7e,%eax
  cmp    %eax,%r11d
  cmovle %r11d,%eax
  movzwl %ax,%ecx
  sub    %ecx,%r11d
  lea    0x1(%rdx),%r12
  mov    %eax,%ecx
  or     $0xffffff80,%ecx
  mov    %cl,(%rdx)
  lea    -0x1(%rax),%esi
  test   %ax,%ax
  je     L106
  movzwl %si,%esi
  lea    0x1(%rsi),%rbx
  mov    $0x0,%eax
L663:
  movzwl (%rdi,%rax,2),%ecx
  mov    %cl,0x1(%rdx,%rax,1)
  mov    %rax,%rcx
  add    $0x1,%rax
  cmp    %rcx,%rsi
  jne    L663
  lea    (%rdi,%rbx,2),%rdi
  lea    (%r12,%rbx,1),%rdx
  jmp    L315
L176:
  mov    %r9,%rdx
L451:
  movb   $0x0,(%rdx)
  lea    0x1(%rdx),%rax
  sub    %r9d,%eax
  jmp    L404
L576:
  test   %r10b,%r10b
  je     L133
  test   %al,%al
  je     L133
  movslq %r8d,%r8
  lea    (%rdi,%r8,2),%r11
  cmp    %r11,%rdi
  jae    L168
  mov    %r9,%rdx
  jmp    L636
L711:
  add    $0x2,%r8
  cmp    %r8,%r11
  jbe    L602
L302:
  movzwl -0x2(%r8),%eax
  cmp    %ax,-0x4(%r8)
  jne    L711
  cmp    (%r8),%ax
  jne    L711
L602:
  lea    -0x4(%r8),%rbx
  mov    %rbx,%rax
  sub    %rdi,%rax
  sar    %rax
  mov    %eax,%r10d
  test   %eax,%eax
  je     L744
L850:
  mov    $0x7e,%eax
  cmp    %eax,%r10d
  cmovle %r10d,%eax
  movzwl %ax,%ecx
  sub    %ecx,%r10d
  lea    0x2(%rdx),%rbp
  mov    %eax,%ecx
  or     $0x80,%cl
  mov    %cx,(%rdx)
  lea    -0x1(%rax),%ecx
  test   %ax,%ax
  je     L220
  movzwl %cx,%ecx
  lea    0x2(%rcx,%rcx,1),%rsi
  mov    $0x0,%eax
L623:
  movzwl (%rdi,%rax,1),%ecx
  mov    %cx,0x2(%rdx,%rax,1)
  add    $0x2,%rax
  cmp    %rax,%rsi
  jne    L623
  add    %rsi,%rdi
  lea    0x0(%rbp,%rsi,1),%rdx
L633:
  test   %r10d,%r10d
  jne    L850
L744:
  lea    -0x2(%r8),%rdi
  movzwl -0x4(%r8),%r8d
  cmp    %rdi,%r11
  jbe    L36
L344:
  cmp    %r8w,(%rdi)
  jne    L710
  add    $0x2,%rdi
  cmp    %rdi,%r11
  ja     L344
L36:
  mov    %rdi,%rax
  sub    %rbx,%rax
  sar    %rax
  mov    %eax,%ecx
  test   %eax,%eax
  je     L504
L299:
  mov    $0x7e,%eax
  cmp    %eax,%ecx
  cmovle %ecx,%eax
  movzwl %ax,%esi
  mov    %ax,(%rdx)
  add    $0x4,%rdx
  mov    %r8w,-0x2(%rdx)
  sub    %esi,%ecx
  jne    L299
L336:
  cmp    %r11,%rdi
  jae    L504
L636:
  lea    0x4(%rdi),%r8
  cmp    %r8,%r11
  ja     L302
  jmp    L602
L220:
  mov    %rbp,%rdx
  jmp    L633
L710:
  mov    %rdi,%rax
  sub    %rbx,%rax
  sar    %rax
  mov    %eax,%ecx
  test   %eax,%eax
  jne    L299
  jmp    L336
L168:
  mov    %r9,%rdx
L504:
  movw   $0x0,(%rdx)
  lea    0x2(%rdx),%rax
  sub    %r9,%rax
  sar    %rax
  jmp    L404
L133:
  lea    D2(%rip),%rdi
  call   <i_errhdlr@plt>
  mov    $0x0,%eax
  jmp    L404
```

tool_calls: name: read_data
arguments: tag: D2
type: string

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