user: Please show me the C implementation that matches the assembly code listed below:

```asm
<decompress>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,0x10(%rsp)
  mov    %rsi,0x18(%rsp)
  mov    %rdx,%r13
  mov    %rcx,%r14
  test   %rcx,%rcx
  je     L377
  cmpb   $0x54,(%rdx)
  je     L151
L171:
  lea    D83(%rip),%rdi
  call   <error@plt>
L151:
  cmp    $0x1,%r14
  jbe    L19
  cmpb   $0x49,0x1(%r13)
  je     L22
L116:
  lea    D83(%rip),%rdi
  call   <error@plt>
L22:
  cmp    $0x2,%r14
  jbe    L192
  cmpb   $0x4e,0x2(%r13)
  je     L327
L379:
  lea    D83(%rip),%rdi
  call   <error@plt>
L327:
  cmp    $0x3,%r14
  jbe    L314
L24:
  cmpb   $0x59,0x3(%r13)
  jne    L61
L265:
  movq   $0x0,0x8(%rsp)
  mov    $0x4,%ebp
  jmp    L253
L377:
  lea    D124(%rip),%rdi
  call   <error@plt>
  cmpb   $0x54,0x0(%r13)
  jne    L171
L19:
  lea    D124(%rip),%rdi
  call   <error@plt>
  cmpb   $0x49,0x1(%r13)
  jne    L116
L192:
  lea    D124(%rip),%rdi
  call   <error@plt>
  cmpb   $0x4e,0x2(%r13)
  jne    L379
L314:
  lea    D124(%rip),%rdi
  call   <error@plt>
  jmp    L24
L61:
  lea    D83(%rip),%rdi
  call   <error@plt>
  jmp    L265
L70:
  mov    %rbx,%rbp
  jmp    L253
L338:
  lea    D124(%rip),%rdi
  call   <error@plt>
  jmp    L288
L337:
  mov    0x10(%rsp),%rsi
  mov    0x8(%rsp),%rax
  mov    %bpl,(%rsi,%rax,1)
  lea    0x1(%rax),%rax
  mov    %rax,0x8(%rsp)
  mov    %rbx,%rbp
L253:
  cmp    %r14,%rbp
  jae    L338
L288:
  lea    0x1(%rbp),%rbx
  movzbl 0x0(%r13,%rbp,1),%ebp
  cmp    $0xff,%bpl
  je     L63
  mov    0x18(%rsp),%rsi
  cmp    %rsi,0x8(%rsp)
  jb     L337
  lea    D50(%rip),%rdi
  call   <error@plt>
  jmp    L337
L63:
  mov    $0x0,%ebp
  mov    $0x0,%r12d
  jmp    L285
L224:
  add    $0x1,%rbx
  movzbl -0x1(%r13,%rbx,1),%edx
  mov    %rdx,%rax
  and    $0x7f,%eax
  mov    %ebp,%ecx
  shl    %cl,%rax
  or     %rax,%r12
  add    $0x7,%ebp
  test   %dl,%dl
  jns    L141
L285:
  cmp    %r14,%rbx
  jb     L224
  lea    D124(%rip),%rdi
  call   <error@plt>
  jmp    L224
L141:
  mov    $0x0,%ebp
  mov    $0x0,%r15d
  jmp    L376
L250:
  add    $0x1,%rbx
  movzbl -0x1(%r13,%rbx,1),%edx
  mov    %rdx,%rax
  and    $0x7f,%eax
  mov    %ebp,%ecx
  shl    %cl,%rax
  or     %rax,%r15
  add    $0x7,%ebp
  test   %dl,%dl
  jns    L249
L376:
  cmp    %r14,%rbx
  jb     L250
  lea    D124(%rip),%rdi
  call   <error@plt>
  jmp    L250
L249:
  test   %r12,%r12
  jne    L293
  test   %r15,%r15
  je     L198
  cmp    $0x1,%r15
  jne    L124
  mov    0x18(%rsp),%rsi
  cmp    %rsi,0x8(%rsp)
  jae    L324
L217:
  mov    0x10(%rsp),%rsi
  mov    0x8(%rsp),%rax
  movb   $0xff,(%rsi,%rax,1)
  lea    0x1(%rax),%rax
  mov    %rax,0x8(%rsp)
  mov    %rbx,%rbp
  jmp    L253
L293:
  test   %r15,%r15
  je     L70
  mov    0x8(%rsp),%rsi
  mov    %rsi,%rax
  sub    %r12,%rax
  mov    0x10(%rsp),%rdi
  add    %rdi,%rax
  add    %rsi,%rdi
  mov    %rdi,%rcx
  sub    %r12,%rcx
  add    %r15,%rcx
L62:
  movzbl (%rax),%edx
  mov    %dl,(%rax,%r12,1)
  add    $0x1,%rax
  cmp    %rcx,%rax
  jne    L62
  add    %r15,0x8(%rsp)
  mov    %rbx,%rbp
  jmp    L253
L324:
  lea    D50(%rip),%rdi
  call   <error@plt>
  jmp    L217
L124:
  lea    D2(%rip),%rdi
  call   <error@plt>
  mov    %rbx,%rbp
  jmp    L253
L198:
  mov    0x8(%rsp),%rax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: disassemble_data
arguments: data_label: D83
datatype: string
name: disassemble_data
arguments: data_label: D124
datatype: string
name: disassemble_data
arguments: data_label: D50
datatype: string
name: disassemble_data
arguments: data_label: D2
datatype: string

tool: D83: bad magic

tool: D124: input underflow

tool: D50: destination overflow

tool: D2: invalid special command

assistant: ```c
size_t decompress(char *dst, size_t dst_sz, char *src, size_t src_sz) {
  size_t src_pos = 0;
  size_t dst_pos = 0;
  unsigned char c;
  do {
    if (src_pos >= src_sz)
      error("input underflow");
    c = src[src_pos++];
  } while (0);
  if (c != 'T')
    error("bad magic");
  do {
    if (src_pos >= src_sz)
      error("input underflow");
    c = src[src_pos++];
  } while (0);
  if (c != 'I')
    error("bad magic");
  do {
    if (src_pos >= src_sz)
      error("input underflow");
    c = src[src_pos++];
  } while (0);
  if (c != 'N')
    error("bad magic");
  do {
    if (src_pos >= src_sz)
      error("input underflow");
    c = src[src_pos++];
  } while (0);
  if (c != 'Y')
    error("bad magic");
  while (1) {
    do {
      if (src_pos >= src_sz)
        error("input underflow");
      c = src[src_pos++];
    } while (0);
    if (c != 0xff) {
      do {
        if (dst_pos >= dst_sz) {
          error("destination overflow");
        }
        dst[dst_pos++] = (c);
      } while (0);
    } else {
      size_t delta, length;
      do {
        delta = 0;
        int shift = 0;
        while (1) {
          unsigned char cc;
          do {
            if (src_pos >= src_sz)
              error("input underflow");
            cc = src[src_pos++];
          } while (0);
          delta |= ((size_t)(cc & 0x7fu)) << shift;
          shift += 7;
          if (!(cc & 128)) {
            break;
          }
        }
      } while (0);
      do {
        length = 0;
        int shift = 0;
        while (1) {
          unsigned char cc;
          do {
            if (src_pos >= src_sz)
              error("input underflow");
            cc = src[src_pos++];
          } while (0);
          length |= ((size_t)(cc & 0x7fu)) << shift;
          shift += 7;
          if (!(cc & 128)) {
            break;
          }
        }
      } while (0);
      if (delta != 0) {
        for (size_t i = 0; i < length; i++) {
          dst[dst_pos] = dst[dst_pos - delta];
          dst_pos++;
        }
      } else {
        if (length == 0) {
          break;
        } else if (length == 1) {
          do {
            if (dst_pos >= dst_sz) {
              error("destination overflow");
            }
            dst[dst_pos++] = (0xff);
          } while (0);
        } else {
          error("invalid special command");
        }
      }
    }
  }
  return dst_pos;
}
```