user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<fits_rdecomp_byte>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %esi,-0x4c(%rbp)
  mov    %rdx,-0x58(%rbp)
  mov    %ecx,-0x50(%rbp)
  mov    %r8d,-0x5c(%rbp)
  movl   $0x3,-0x18(%rbp)
  movl   $0x6,-0x14(%rbp)
  mov    -0x18(%rbp),%eax
  mov    $0x1,%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %eax,-0x10(%rbp)
  mov    D33(%rip),%rax
  test   %rax,%rax
  jne    L185
  mov    $0x400,%edi
  call   <malloc@plt>
  mov    %rax,D9(%rip)
  mov    D9(%rip),%rax
  test   %rax,%rax
  jne    L315
  lea    D9(%rip),%rax
  mov    %rax,%rdi
  call   <ffpmsg@plt>
  mov    $0x1,%eax
  jmp    L38
L315:
  movl   $0x8,-0x28(%rbp)
  movl   $0x80,-0x30(%rbp)
  movl   $0xff,-0x38(%rbp)
  jmp    L164
L299:
  mov    D9(%rip),%rdx
  mov    -0x38(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rax,%rdx
  mov    -0x28(%rbp),%eax
  mov    %eax,(%rdx)
  subl   $0x1,-0x38(%rbp)
L264:
  mov    -0x38(%rbp),%eax
  cmp    -0x30(%rbp),%eax
  jge    L299
  mov    -0x30(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x30(%rbp)
  subl   $0x1,-0x28(%rbp)
L164:
  cmpl   $0x0,-0x38(%rbp)
  jns    L264
L185:
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x1c(%rbp)
  addq   $0x1,-0x48(%rbp)
  mov    -0x4c(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x48(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x48(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x24(%rbp)
  movl   $0x8,-0x2c(%rbp)
  movl   $0x0,-0x38(%rbp)
  jmp    L79
L262:
  mov    -0x18(%rbp),%eax
  sub    %eax,-0x2c(%rbp)
  jmp    L118
L256:
  mov    -0x24(%rbp),%eax
  shl    $0x8,%eax
  mov    %eax,%ecx
  mov    -0x48(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x48(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  or     %ecx,%eax
  mov    %eax,-0x24(%rbp)
  addl   $0x8,-0x2c(%rbp)
L118:
  cmpl   $0x0,-0x2c(%rbp)
  js     L256
  mov    -0x2c(%rbp),%eax
  mov    -0x24(%rbp),%edx
  mov    %eax,%ecx
  shr    %cl,%edx
  mov    %edx,%eax
  sub    $0x1,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x2c(%rbp),%eax
  mov    $0x1,%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  sub    $0x1,%eax
  and    %eax,-0x24(%rbp)
  mov    -0x38(%rbp),%edx
  mov    -0x5c(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x34(%rbp)
  mov    -0x34(%rbp),%eax
  cmp    -0x50(%rbp),%eax
  jle    L104
  mov    -0x50(%rbp),%eax
  mov    %eax,-0x34(%rbp)
L104:
  cmpl   $0x0,-0xc(%rbp)
  jns    L161
  jmp    L208
L316:
  mov    -0x38(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  mov    -0x1c(%rbp),%edx
  mov    %dl,(%rax)
  addl   $0x1,-0x38(%rbp)
L208:
  mov    -0x38(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jl     L316
  jmp    L61
L161:
  mov    -0xc(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jne    L310
  jmp    L105
L11:
  mov    -0x10(%rbp),%eax
  sub    -0x2c(%rbp),%eax
  mov    %eax,-0x30(%rbp)
  mov    -0x30(%rbp),%eax
  mov    -0x24(%rbp),%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %eax,-0x20(%rbp)
  subl   $0x8,-0x30(%rbp)
  jmp    L191
L91:
  mov    -0x48(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x48(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x24(%rbp)
  mov    -0x30(%rbp),%eax
  mov    -0x24(%rbp),%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  or     %eax,-0x20(%rbp)
  subl   $0x8,-0x30(%rbp)
L191:
  cmpl   $0x0,-0x30(%rbp)
  jns    L91
  cmpl   $0x0,-0x2c(%rbp)
  jle    L306
  mov    -0x48(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x48(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x24(%rbp)
  mov    -0x30(%rbp),%eax
  neg    %eax
  mov    -0x24(%rbp),%edx
  mov    %eax,%ecx
  shr    %cl,%edx
  mov    %edx,%eax
  or     %eax,-0x20(%rbp)
  mov    -0x2c(%rbp),%eax
  mov    $0x1,%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  sub    $0x1,%eax
  and    %eax,-0x24(%rbp)
  jmp    L216
L306:
  movl   $0x0,-0x24(%rbp)
L216:
  mov    -0x20(%rbp),%eax
  and    $0x1,%eax
  test   %eax,%eax
  jne    L116
  shrl   -0x20(%rbp)
  jmp    L167
L116:
  mov    -0x20(%rbp),%eax
  shr    %eax
  not    %eax
  mov    %eax,-0x20(%rbp)
L167:
  mov    -0x20(%rbp),%eax
  mov    %eax,%esi
  mov    -0x1c(%rbp),%eax
  mov    %eax,%ecx
  mov    -0x38(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  lea    (%rsi,%rcx,1),%edx
  mov    %dl,(%rax)
  mov    -0x38(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x1c(%rbp)
  addl   $0x1,-0x38(%rbp)
L105:
  mov    -0x38(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jl     L11
  jmp    L61
L106:
  addl   $0x8,-0x2c(%rbp)
  mov    -0x48(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x48(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x24(%rbp)
L176:
  cmpl   $0x0,-0x24(%rbp)
  je     L106
  mov    D9(%rip),%rdx
  mov    -0x24(%rbp),%eax
  shl    $0x2,%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x2c(%rbp),%eax
  sub    %edx,%eax
  mov    %eax,-0x28(%rbp)
  mov    -0x28(%rbp),%eax
  add    $0x1,%eax
  sub    %eax,-0x2c(%rbp)
  mov    -0x2c(%rbp),%eax
  mov    $0x1,%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  xor    %eax,-0x24(%rbp)
  mov    -0xc(%rbp),%eax
  sub    %eax,-0x2c(%rbp)
  jmp    L277
L319:
  mov    -0x24(%rbp),%eax
  shl    $0x8,%eax
  mov    %eax,%ecx
  mov    -0x48(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x48(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  or     %ecx,%eax
  mov    %eax,-0x24(%rbp)
  addl   $0x8,-0x2c(%rbp)
L277:
  cmpl   $0x0,-0x2c(%rbp)
  js     L319
  mov    -0xc(%rbp),%eax
  mov    -0x28(%rbp),%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %eax,%esi
  mov    -0x2c(%rbp),%eax
  mov    -0x24(%rbp),%edx
  mov    %eax,%ecx
  shr    %cl,%edx
  mov    %edx,%eax
  or     %esi,%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x2c(%rbp),%eax
  mov    $0x1,%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  sub    $0x1,%eax
  and    %eax,-0x24(%rbp)
  mov    -0x20(%rbp),%eax
  and    $0x1,%eax
  test   %eax,%eax
  jne    L218
  shrl   -0x20(%rbp)
  jmp    L214
L218:
  mov    -0x20(%rbp),%eax
  shr    %eax
  not    %eax
  mov    %eax,-0x20(%rbp)
L214:
  mov    -0x20(%rbp),%eax
  mov    %eax,%esi
  mov    -0x1c(%rbp),%eax
  mov    %eax,%ecx
  mov    -0x38(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  lea    (%rsi,%rcx,1),%edx
  mov    %dl,(%rax)
  mov    -0x38(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x1c(%rbp)
  addl   $0x1,-0x38(%rbp)
L310:
  mov    -0x38(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jl     L176
L61:
  mov    -0x48(%rbp),%rax
  cmp    -0x8(%rbp),%rax
  jbe    L79
  lea    D21(%rip),%rax
  mov    %rax,%rdi
  call   <ffpmsg@plt>
  mov    $0x1,%eax
  jmp    L38
L79:
  mov    -0x38(%rbp),%eax
  cmp    -0x50(%rbp),%eax
  jl     L262
  mov    -0x48(%rbp),%rax
  cmp    -0x8(%rbp),%rax
  jae    L259
  lea    D15(%rip),%rax
  mov    %rax,%rdi
  call   <ffpmsg@plt>
L259:
  mov    $0x0,%eax
L38:
  leave
  ret
```

tool_calls: name: read_data
arguments: tag: D9
type_infered: string
name: read_data
arguments: tag: D21
type_infered: string
name: read_data
arguments: tag: D15
type_infered: string

tool: D9: rdecomp: insufficient memory

tool: D21: decompression error: hit end of compressed byte stream

tool: D15: decompression warning: unused bytes at end of compressed buffer

assistant: ```c
int fits_rdecomp_byte(unsigned char *c, int clen, unsigned char array[], int nx, int nblock) {
  int i, imax;
  int k;
  int nbits, nzero, fs;
  unsigned char *cend;
  unsigned int b, diff, lastpix;
  int fsmax, fsbits, bbits;
  static int *nonzero_count = (int *)NULL;
  fsbits = 3;
  fsmax = 6;
  bbits = 1 << fsbits;
  ;
  if (nonzero_count == (int *)NULL) {
    nonzero_count = (int *)malloc(256 * sizeof(int));
    if (nonzero_count == (int *)NULL) {
      ffpmsg("rdecomp: insufficient memory");
      ;
      return 1;
    }
    nzero = 8;
    k = 128;
    for (i = 255; i >= 0;) {
      for (; i >= k; i--)
        nonzero_count[i] = nzero;
      k = k / 2;
      nzero--;
    }
  };
  lastpix = c[0];
  c += 1;
  cend = c + clen - 1;
  b = *c++;
  nbits = 8;
  for (i = 0; i < nx;) {
    nbits -= fsbits;
    while (nbits < 0) {
      b = (b << 8) | (*c++);
      nbits += 8;
    }
    fs = (b >> nbits) - 1;
    b &= (1 << nbits) - 1;
    imax = i + nblock;
    if (imax > nx)
      imax = nx;
    if (fs < 0) {
      for (; i < imax; i++)
        array[i] = lastpix;
    } else if (fs == fsmax) {
      for (; i < imax; i++) {
        k = bbits - nbits;
        diff = b << k;
        for (k -= 8; k >= 0; k -= 8) {
          b = *c++;
          diff |= b << k;
        }
        if (nbits > 0) {
          b = *c++;
          diff |= b >> (-k);
          b &= (1 << nbits) - 1;
        } else {
          b = 0;
        }
        if ((diff & 1) == 0) {
          diff = diff >> 1;
        } else {
          diff = ~(diff >> 1);
        }
        array[i] = diff + lastpix;
        lastpix = array[i];
      }
    } else {
      for (; i < imax; i++) {
        while (b == 0) {
          nbits += 8;
          b = *c++;
        }
        nzero = nbits - nonzero_count[b];
        nbits -= nzero + 1;
        b ^= 1 << nbits;
        nbits -= fs;
        while (nbits < 0) {
          b = (b << 8) | (*c++);
          nbits += 8;
        }
        diff = (nzero << fs) | (b >> nbits);
        b &= (1 << nbits) - 1;
        if ((diff & 1) == 0) {
          diff = diff >> 1;
        } else {
          diff = ~(diff >> 1);
        }
        array[i] = diff + lastpix;
        lastpix = array[i];
      }
    }
    if (c > cend) {
      ffpmsg("decompression error: hit end of compressed byte stream");
      return 1;
    }
  }
  if (c < cend) {
    ffpmsg("decompression warning: unused bytes at end of compressed buffer");
  }
  return 0;
}
```