user: Demonstrate the C code that generates the assembly output below:

```asm
<img_rle_compact>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %ecx,-0x40(%rbp)
  mov    %r8d,-0x4c(%rbp)
  cmpl   $0x1,-0x3c(%rbp)
  jne    L350
  cmpl   $0x1,-0x40(%rbp)
  jne    L350
  mov    -0x38(%rbp),%rbx
  mov    -0x4c(%rbp),%eax
  cltq
  lea    (%rbx,%rax,1),%r15
  mov    -0x48(%rbp),%r12
  jmp    L130
L463:
  mov    %rbx,%rdi
  add    $0x2,%rbx
  jmp    L129
L4:
  add    $0x1,%rbx
L129:
  cmp    %r15,%rbx
  jae    L6
  lea    -0x2(%rbx),%rax
  movzbl (%rax),%edx
  lea    -0x1(%rbx),%rax
  movzbl (%rax),%eax
  cmp    %al,%dl
  jne    L4
  lea    -0x1(%rbx),%rax
  movzbl (%rax),%edx
  movzbl (%rbx),%eax
  cmp    %al,%dl
  jne    L4
L6:
  sub    $0x2,%rbx
  mov    %rbx,%rax
  sub    %rdi,%rax
  mov    %eax,%r13d
  jmp    L164
L709:
  mov    $0x7e,%eax
  cmp    %eax,%r13d
  cmovle %r13d,%eax
  mov    %eax,%r14d
  movswl %r14w,%eax
  sub    %eax,%r13d
  mov    %r14d,%eax
  or     $0xffffff80,%eax
  mov    %eax,%edx
  mov    %r12,%rax
  lea    0x1(%rax),%r12
  mov    %dl,(%rax)
  jmp    L204
L714:
  mov    %rdi,%rdx
  lea    0x1(%rdx),%rax
  mov    %rax,%rdi
  mov    %r12,%rax
  lea    0x1(%rax),%r12
  movzbl (%rdx),%edx
  mov    %dl,(%rax)
L204:
  mov    %r14d,%eax
  mov    %eax,%edx
  sub    $0x1,%edx
  mov    %edx,%r14d
  test   %ax,%ax
  jne    L714
L164:
  test   %r13d,%r13d
  jne    L709
  mov    %rbx,%rdi
  mov    %rbx,%rax
  lea    0x1(%rax),%rbx
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,%ecx
  jmp    L442
L532:
  add    $0x1,%rbx
L442:
  cmp    %r15,%rbx
  jae    L115
  movzbl (%rbx),%eax
  movzbl %al,%edx
  mov    %ecx,%eax
  cwtl
  cmp    %eax,%edx
  je     L532
L115:
  mov    %rbx,%rax
  sub    %rdi,%rax
  mov    %eax,%r13d
  jmp    L1
L140:
  mov    $0x7e,%eax
  cmp    %eax,%r13d
  cmovle %r13d,%eax
  mov    %eax,%r14d
  movswl %r14w,%eax
  sub    %eax,%r13d
  mov    %r12,%rax
  lea    0x1(%rax),%r12
  mov    %r14d,%edx
  mov    %dl,(%rax)
  mov    %r12,%rax
  lea    0x1(%rax),%r12
  mov    %ecx,%edx
  mov    %dl,(%rax)
L1:
  test   %r13d,%r13d
  jne    L140
L130:
  cmp    %r15,%rbx
  jb     L463
  mov    %r12,%rax
  lea    0x1(%rax),%r12
  movb   $0x0,(%rax)
  mov    %r12,%rax
  sub    -0x48(%rbp),%rax
  jmp    L287
L350:
  cmpl   $0x1,-0x3c(%rbp)
  jne    L498
  cmpl   $0x2,-0x40(%rbp)
  jne    L498
  mov    -0x38(%rbp),%rbx
  mov    -0x4c(%rbp),%eax
  cltq
  lea    (%rbx,%rax,1),%r15
  mov    -0x48(%rbp),%r12
  jmp    L438
L403:
  mov    %rbx,%rcx
  add    $0x2,%rbx
  jmp    L336
L641:
  add    $0x1,%rbx
L336:
  cmp    %r15,%rbx
  jae    L49
  lea    -0x2(%rbx),%rax
  movzbl (%rax),%edx
  lea    -0x1(%rbx),%rax
  movzbl (%rax),%eax
  cmp    %al,%dl
  jne    L641
  lea    -0x1(%rbx),%rax
  movzbl (%rax),%edx
  movzbl (%rbx),%eax
  cmp    %al,%dl
  jne    L641
L49:
  sub    $0x2,%rbx
  mov    %rbx,%rax
  sub    %rcx,%rax
  mov    %eax,%r13d
  jmp    L522
L57:
  mov    $0x7e,%eax
  cmp    %eax,%r13d
  cmovle %r13d,%eax
  mov    %eax,%r14d
  movswl %r14w,%eax
  sub    %eax,%r13d
  mov    %r14d,%edx
  or     $0x80,%dl
  mov    %r12,%rax
  lea    0x2(%rax),%r12
  mov    %dx,(%rax)
  jmp    L484
L153:
  mov    %rcx,%rax
  lea    0x1(%rax),%rcx
  movzbl (%rax),%edx
  mov    %r12,%rax
  lea    0x2(%rax),%r12
  movzbl %dl,%edx
  mov    %dx,(%rax)
L484:
  mov    %r14d,%eax
  mov    %eax,%edx
  sub    $0x1,%edx
  mov    %edx,%r14d
  test   %ax,%ax
  jne    L153
L522:
  test   %r13d,%r13d
  jne    L57
  mov    %rbx,%rcx
  mov    %rbx,%rax
  lea    0x1(%rax),%rbx
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,%esi
  jmp    L679
L184:
  add    $0x1,%rbx
L679:
  cmp    %r15,%rbx
  jae    L201
  movzbl (%rbx),%eax
  movzbl %al,%edx
  mov    %esi,%eax
  cwtl
  cmp    %eax,%edx
  je     L184
L201:
  mov    %rbx,%rax
  sub    %rcx,%rax
  mov    %eax,%r13d
  jmp    L594
L489:
  mov    $0x7e,%eax
  cmp    %eax,%r13d
  cmovle %r13d,%eax
  mov    %eax,%r14d
  movswl %r14w,%eax
  sub    %eax,%r13d
  mov    %r12,%rax
  lea    0x2(%rax),%r12
  mov    %r14d,%edx
  mov    %dx,(%rax)
  mov    %r12,%rax
  lea    0x2(%rax),%r12
  mov    %esi,%edx
  mov    %dx,(%rax)
L594:
  test   %r13d,%r13d
  jne    L489
L438:
  cmp    %r15,%rbx
  jb     L403
  mov    %r12,%rax
  lea    0x2(%rax),%r12
  movw   $0x0,(%rax)
  mov    %r12,%rax
  sub    -0x48(%rbp),%rax
  sar    %rax
  jmp    L287
L498:
  cmpl   $0x2,-0x3c(%rbp)
  jne    L362
  cmpl   $0x1,-0x40(%rbp)
  jne    L362
  mov    -0x38(%rbp),%rbx
  mov    -0x4c(%rbp),%eax
  cltq
  add    %rax,%rax
  lea    (%rbx,%rax,1),%r15
  mov    -0x48(%rbp),%r12
  jmp    L683
L680:
  mov    %rbx,%rsi
  add    $0x4,%rbx
  jmp    L167
L676:
  add    $0x2,%rbx
L167:
  cmp    %r15,%rbx
  jae    L41
  lea    -0x4(%rbx),%rax
  movzwl (%rax),%edx
  lea    -0x2(%rbx),%rax
  movzwl (%rax),%eax
  cmp    %ax,%dx
  jne    L676
  lea    -0x2(%rbx),%rax
  movzwl (%rax),%edx
  movzwl (%rbx),%eax
  cmp    %ax,%dx
  jne    L676
L41:
  sub    $0x4,%rbx
  mov    %rbx,%rax
  sub    %rsi,%rax
  sar    %rax
  mov    %eax,%r13d
  jmp    L144
L107:
  mov    $0x7e,%eax
  cmp    %eax,%r13d
  cmovle %r13d,%eax
  mov    %eax,%r14d
  movswl %r14w,%eax
  sub    %eax,%r13d
  mov    %r14d,%eax
  or     $0xffffff80,%eax
  mov    %eax,%edx
  mov    %r12,%rax
  lea    0x1(%rax),%r12
  mov    %dl,(%rax)
  jmp    L452
L704:
  mov    %rsi,%rax
  lea    0x2(%rax),%rsi
  movzwl (%rax),%edx
  mov    %r12,%rax
  lea    0x1(%rax),%r12
  mov    %dl,(%rax)
L452:
  mov    %r14d,%eax
  mov    %eax,%edx
  sub    $0x1,%edx
  mov    %edx,%r14d
  test   %ax,%ax
  jne    L704
L144:
  test   %r13d,%r13d
  jne    L107
  mov    %rbx,%rsi
  mov    %rbx,%rax
  lea    0x2(%rax),%rbx
  movzwl (%rax),%eax
  mov    %eax,%ecx
  jmp    L341
L576:
  add    $0x2,%rbx
L341:
  cmp    %r15,%rbx
  jae    L0
  movzwl (%rbx),%eax
  movzwl %ax,%edx
  mov    %ecx,%eax
  cwtl
  cmp    %eax,%edx
  je     L576
L0:
  mov    %rbx,%rax
  sub    %rsi,%rax
  sar    %rax
  mov    %eax,%r13d
  jmp    L600
L277:
  mov    $0x7e,%eax
  cmp    %eax,%r13d
  cmovle %r13d,%eax
  mov    %eax,%r14d
  movswl %r14w,%eax
  sub    %eax,%r13d
  mov    %r12,%rax
  lea    0x1(%rax),%r12
  mov    %r14d,%edx
  mov    %dl,(%rax)
  mov    %r12,%rax
  lea    0x1(%rax),%r12
  mov    %ecx,%edx
  mov    %dl,(%rax)
L600:
  test   %r13d,%r13d
  jne    L277
L683:
  cmp    %r15,%rbx
  jb     L680
  mov    %r12,%rax
  lea    0x1(%rax),%r12
  movb   $0x0,(%rax)
  mov    %r12,%rax
  sub    -0x48(%rbp),%rax
  jmp    L287
L362:
  cmpl   $0x2,-0x3c(%rbp)
  jne    L105
  cmpl   $0x2,-0x40(%rbp)
  jne    L105
  mov    -0x38(%rbp),%rbx
  mov    -0x4c(%rbp),%eax
  cltq
  add    %rax,%rax
  lea    (%rbx,%rax,1),%r15
  mov    -0x48(%rbp),%r12
  jmp    L494
L62:
  mov    %rbx,%rdi
  add    $0x4,%rbx
  jmp    L137
L467:
  add    $0x2,%rbx
L137:
  cmp    %r15,%rbx
  jae    L402
  lea    -0x4(%rbx),%rax
  movzwl (%rax),%edx
  lea    -0x2(%rbx),%rax
  movzwl (%rax),%eax
  cmp    %ax,%dx
  jne    L467
  lea    -0x2(%rbx),%rax
  movzwl (%rax),%edx
  movzwl (%rbx),%eax
  cmp    %ax,%dx
  jne    L467
L402:
  sub    $0x4,%rbx
  mov    %rbx,%rax
  sub    %rdi,%rax
  sar    %rax
  mov    %eax,%r13d
  jmp    L156
L361:
  mov    $0x7e,%eax
  cmp    %eax,%r13d
  cmovle %r13d,%eax
  mov    %eax,%r14d
  movswl %r14w,%eax
  sub    %eax,%r13d
  mov    %r14d,%edx
  or     $0x80,%dl
  mov    %r12,%rax
  lea    0x2(%rax),%r12
  mov    %dx,(%rax)
  jmp    L363
L76:
  mov    %rdi,%rdx
  lea    0x2(%rdx),%rax
  mov    %rax,%rdi
  mov    %r12,%rax
  lea    0x2(%rax),%r12
  movzwl (%rdx),%edx
  mov    %dx,(%rax)
L363:
  mov    %r14d,%eax
  mov    %eax,%edx
  sub    $0x1,%edx
  mov    %edx,%r14d
  test   %ax,%ax
  jne    L76
L156:
  test   %r13d,%r13d
  jne    L361
  mov    %rbx,%rdi
  mov    %rbx,%rax
  lea    0x2(%rax),%rbx
  movzwl (%rax),%eax
  mov    %eax,%esi
  jmp    L313
L13:
  add    $0x2,%rbx
L313:
  cmp    %r15,%rbx
  jae    L479
  movzwl (%rbx),%eax
  movzwl %ax,%edx
  mov    %esi,%eax
  cwtl
  cmp    %eax,%edx
  je     L13
L479:
  mov    %rbx,%rax
  sub    %rdi,%rax
  sar    %rax
  mov    %eax,%r13d
  jmp    L672
L347:
  mov    $0x7e,%eax
  cmp    %eax,%r13d
  cmovle %r13d,%eax
  mov    %eax,%r14d
  movswl %r14w,%eax
  sub    %eax,%r13d
  mov    %r12,%rax
  lea    0x2(%rax),%r12
  mov    %r14d,%edx
  mov    %dx,(%rax)
  mov    %r12,%rax
  lea    0x2(%rax),%r12
  mov    %esi,%edx
  mov    %dx,(%rax)
L672:
  test   %r13d,%r13d
  jne    L347
L494:
  cmp    %r15,%rbx
  jb     L62
  mov    %r12,%rax
  lea    0x2(%rax),%r12
  movw   $0x0,(%rax)
  mov    %r12,%rax
  sub    -0x48(%rbp),%rax
  sar    %rax
  jmp    L287
L105:
  mov    -0x40(%rbp),%edx
  mov    -0x3c(%rbp),%eax
  mov    %eax,%esi
  lea    D5(%rip),%rax
  mov    %rax,%rdi
  call   <i_errhdlr@plt>
  mov    $0x0,%eax
L287:
  add    $0x28,%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
```

tool_calls: name: disassemble_data
arguments: data_label: D5
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;
  }
}
```