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

```asm
<uncompress>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0xc30,%rsp
  mov    %rdi,-0xc28(%rbp)
  mov    %rsi,-0xc30(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0xc1c(%rbp)
  movq   $0x0,-0x810(%rbp)
  movq   $0x0,-0x808(%rbp)
  lea    -0x800(%rbp),%rdx
  mov    $0x0,%eax
  mov    $0xfe,%ecx
  mov    %rdx,%rdi
  rep stos %rax,%es:(%rdi)
  movq   $0x0,-0xc10(%rbp)
  movq   $0x0,-0xc08(%rbp)
  lea    -0xc00(%rbp),%rdx
  mov    $0x0,%eax
  mov    $0x7e,%ecx
  mov    %rdx,%rdi
  rep stos %rax,%es:(%rdi)
  mov    -0xc28(%rbp),%rax
  mov    %rax,%rdx
  lea    D51(%rip),%rax
  mov    %rax,%rsi
  mov    $0x3,%edi
  mov    $0x0,%eax
  call   <trace@plt>
  mov    -0xc28(%rbp),%rdx
  lea    -0xc10(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  lea    -0xc10(%rbp),%rax
  mov    $0x2e,%esi
  mov    %rax,%rdi
  call   <strrchr@plt>
  mov    %rax,-0xc18(%rbp)
  cmpq   $0x0,-0xc18(%rbp)
  jne    L203
  mov    $0x0,%eax
  jmp    L35
L203:
  mov    -0xc18(%rbp),%rax
  lea    D97(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L83
  mov    -0xc18(%rbp),%rax
  lea    D99(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L83
  mov    -0xc18(%rbp),%rax
  lea    D86(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L83
  mov    -0xc18(%rbp),%rax
  lea    D2(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L83
  mov    -0xc18(%rbp),%rax
  lea    D3(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L83
  mov    -0xc18(%rbp),%rax
  lea    D116(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  jne    L28
L83:
  lea    -0xc10(%rbp),%rdx
  mov    -0xc30(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  lea    -0xc10(%rbp),%rdx
  mov    -0xc18(%rbp),%rax
  sub    %rdx,%rax
  mov    %rax,%rdx
  mov    -0xc30(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0xc30(%rbp),%rcx
  lea    -0xc10(%rbp),%rdx
  lea    -0x810(%rbp),%rax
  lea    D114(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  lea    -0x810(%rbp),%rax
  mov    %rax,%rdi
  call   <execcmd@plt>
  test   %rax,%rax
  je     L82
  mov    -0xc30(%rbp),%rax
  mov    %rax,%rdi
  call   <remove@plt>
  mov    $0xffffffff,%eax
  jmp    L35
L82:
  mov    -0xc30(%rbp),%rdx
  lea    -0xc10(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  movl   $0x1,-0xc1c(%rbp)
L28:
  lea    -0xc10(%rbp),%rax
  mov    $0x2e,%esi
  mov    %rax,%rdi
  call   <strrchr@plt>
  mov    %rax,-0xc18(%rbp)
  cmpq   $0x0,-0xc18(%rbp)
  je     L177
  mov    -0xc18(%rbp),%rax
  lea    D79(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  jne    L177
  lea    -0xc10(%rbp),%rdx
  mov    -0xc30(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  lea    -0xc10(%rbp),%rdx
  mov    -0xc18(%rbp),%rax
  sub    %rdx,%rax
  mov    %rax,%rdx
  mov    -0xc30(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  lea    -0xc10(%rbp),%rdx
  lea    -0x810(%rbp),%rax
  lea    D49(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  lea    -0x810(%rbp),%rax
  mov    %rax,%rdi
  call   <execcmd@plt>
  test   %rax,%rax
  je     L105
  cmpl   $0x0,-0xc1c(%rbp)
  je     L231
  lea    -0xc10(%rbp),%rax
  mov    %rax,%rdi
  call   <remove@plt>
L231:
  mov    $0xffffffff,%eax
  jmp    L35
L105:
  cmpl   $0x0,-0xc1c(%rbp)
  je     L37
  lea    -0xc10(%rbp),%rax
  mov    %rax,%rdi
  call   <remove@plt>
L37:
  movl   $0x1,-0xc1c(%rbp)
  jmp    L138
L177:
  lea    -0xc10(%rbp),%rax
  mov    $0x2e,%esi
  mov    %rax,%rdi
  call   <strrchr@plt>
  mov    %rax,-0xc18(%rbp)
  cmpq   $0x0,-0xc18(%rbp)
  je     L138
  mov    -0xc18(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cmp    $0x3,%eax
  jle    L138
  mov    -0xc18(%rbp),%rax
  add    $0x3,%rax
  movzbl (%rax),%eax
  cmp    $0x64,%al
  je     L155
  mov    -0xc18(%rbp),%rax
  add    $0x3,%rax
  movzbl (%rax),%eax
  cmp    $0x44,%al
  jne    L138
L155:
  lea    -0xc10(%rbp),%rdx
  mov    -0xc30(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    -0xc18(%rbp),%rax
  add    $0x3,%rax
  movzbl (%rax),%eax
  cmp    $0x44,%al
  jne    L104
  mov    $0x4f,%edx
  jmp    L48
L104:
  mov    $0x6f,%edx
L48:
  lea    -0xc10(%rbp),%rcx
  mov    -0xc18(%rbp),%rax
  sub    %rcx,%rax
  lea    0x3(%rax),%rcx
  mov    -0xc30(%rbp),%rax
  add    %rcx,%rax
  mov    %dl,(%rax)
  mov    -0xc30(%rbp),%rcx
  lea    -0xc10(%rbp),%rdx
  lea    -0x810(%rbp),%rax
  lea    D23(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  lea    -0x810(%rbp),%rax
  mov    %rax,%rdi
  call   <execcmd@plt>
  test   %rax,%rax
  je     L248
  mov    -0xc30(%rbp),%rax
  mov    %rax,%rdi
  call   <remove@plt>
  cmpl   $0x0,-0xc1c(%rbp)
  je     L43
  lea    -0xc10(%rbp),%rax
  mov    %rax,%rdi
  call   <remove@plt>
L43:
  mov    $0xffffffff,%eax
  jmp    L35
L248:
  cmpl   $0x0,-0xc1c(%rbp)
  je     L255
  lea    -0xc10(%rbp),%rax
  mov    %rax,%rdi
  call   <remove@plt>
L255:
  movl   $0x1,-0xc1c(%rbp)
L138:
  mov    -0xc1c(%rbp),%eax
  mov    %eax,%edx
  lea    D102(%rip),%rax
  mov    %rax,%rsi
  mov    $0x3,%edi
  mov    $0x0,%eax
  call   <trace@plt>
  mov    -0xc1c(%rbp),%eax
L35:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L72
  call   <__stack_chk_fail@plt>
L72:
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: label: D51
type: string
name: disassemble_data
arguments: label: D97
type: string
name: disassemble_data
arguments: label: D99
type: string
name: disassemble_data
arguments: label: D86
type: string
name: disassemble_data
arguments: label: D2
type: string
name: disassemble_data
arguments: label: D3
type: string
name: disassemble_data
arguments: label: D116
type: string
name: disassemble_data
arguments: label: D114
type: string
name: disassemble_data
arguments: label: D79
type: string
name: disassemble_data
arguments: label: D49
type: string
name: disassemble_data
arguments: label: D23
type: string
name: disassemble_data
arguments: label: D102
type: string

tool: D51: uncompress: file=%s


tool: D97: .z

tool: D99: .Z

tool: D86: .gz

tool: D2: .GZ

tool: D3: .zip

tool: D116: .ZIP

tool: D114: gzip -f -d -c "%s" > "%s"

tool: D79: .tar

tool: D49: tar -xf "%s"

tool: D23: crx2rnx < "%s" > "%s"

tool: D102: uncompress: stat=%d


assistant: ```c
extern int uncompress(const char *file, char *uncfile) {
  int stat = 0;
  char *p, cmd[2048] = "", tmpfile[1024] = "";
  trace(3, "uncompress: file=%s\n", file);
  strcpy(tmpfile, file);
  if (!(p = strrchr(tmpfile, '.')))
    return 0;
  if (!strcmp(p, ".z") || !strcmp(p, ".Z") || !strcmp(p, ".gz") || !strcmp(p, ".GZ") || !strcmp(p, ".zip") || !strcmp(p, ".ZIP")) {
    strcpy(uncfile, tmpfile);
    uncfile[p - tmpfile] = '\0';
    sprintf(cmd, "gzip -f -d -c \"%s\" > \"%s\"", tmpfile, uncfile);
    if (execcmd(cmd)) {
      remove(uncfile);
      return -1;
    }
    strcpy(tmpfile, uncfile);
    stat = 1;
  }
  if ((p = strrchr(tmpfile, '.')) && !strcmp(p, ".tar")) {
    strcpy(uncfile, tmpfile);
    uncfile[p - tmpfile] = '\0';
    sprintf(cmd, "tar -xf \"%s\"", tmpfile);
    if (execcmd(cmd)) {
      if (stat)
        remove(tmpfile);
      return -1;
    }
    if (stat)
      remove(tmpfile);
    stat = 1;
  } else if ((p = strrchr(tmpfile, '.')) && strlen(p) > 3 && (*(p + 3) == 'd' || *(p + 3) == 'D')) {
    strcpy(uncfile, tmpfile);
    uncfile[p - tmpfile + 3] = *(p + 3) == 'D' ? 'O' : 'o';
    sprintf(cmd, "crx2rnx < \"%s\" > \"%s\"", tmpfile, uncfile);
    if (execcmd(cmd)) {
      remove(uncfile);
      if (stat)
        remove(tmpfile);
      return -1;
    }
    if (stat)
      remove(tmpfile);
    stat = 1;
  }
  trace(3, "uncompress: stat=%d\n", stat);
  return stat;
}
```