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

```asm
<sortinvoke>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x230,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x220(%rbp),%rax
  mov    %rax,%rdi
  call   <pipe@plt>
  cmp    $0xffffffff,%eax
  je     L232
  lea    -0x218(%rbp),%rax
  mov    %rax,%rdi
  call   <pipe@plt>
  cmp    $0xffffffff,%eax
  jne    L168
L232:
  lea    D102(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  mov    $0xffffffff,%edi
  call   <exit@plt>
L168:
  call   <fork@plt>
  cmp    $0xffffffff,%eax
  je     L207
  test   %eax,%eax
  je     L180
  jmp    L107
L207:
  lea    D129(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  mov    $0xffffffff,%edi
  call   <exit@plt>
L180:
  mov    $0x0,%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  jne    L222
  lea    D58(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
L222:
  mov    -0x220(%rbp),%eax
  mov    %eax,%edi
  call   <dup@plt>
  test   %eax,%eax
  je     L212
  lea    D79(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  mov    $0xfffffffe,%edi
  call   <exit@plt>
L212:
  mov    $0x1,%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  jne    L81
  lea    D58(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
L81:
  mov    -0x214(%rbp),%eax
  mov    %eax,%edi
  call   <dup@plt>
  cmp    $0x1,%eax
  je     L146
  lea    D47(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  mov    $0xfffffffd,%edi
  call   <exit@plt>
L146:
  mov    -0x220(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  je     L253
  mov    -0x21c(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  je     L253
  mov    -0x218(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  je     L253
  mov    -0x214(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  jne    L62
L253:
  lea    D58(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
L62:
  mov    $0x0,%edx
  lea    D75(%rip),%rax
  mov    %rax,%rsi
  lea    D75(%rip),%rax
  mov    %rax,%rdi
  call   <execlp@plt>
  lea    D158(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  mov    $0xfffffffc,%edi
  call   <exit@plt>
L107:
  nop
  mov    -0x220(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  je     L28
  mov    -0x214(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  jne    L53
L28:
  lea    D58(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
L53:
  mov    $0x0,%esi
  lea    D121(%rip),%rax
  mov    %rax,%rdi
  call   <open@plt>
  mov    %eax,-0x228(%rbp)
  cmpl   $0xffffffff,-0x228(%rbp)
  jne    L260
  lea    D87(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  jmp    L260
L34:
  cmpl   $0x1,-0x224(%rbp)
  jne    L205
  lea    D8(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
L205:
  mov    -0x21c(%rbp),%eax
  mov    -0x224(%rbp),%edx
  lea    -0x210(%rbp),%rcx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  cmp    $0xffffffff,%eax
  jne    L260
  lea    D48(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
L260:
  lea    -0x210(%rbp),%rcx
  mov    -0x228(%rbp),%eax
  mov    $0x200,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <read@plt>
  mov    %eax,-0x224(%rbp)
  cmpl   $0x0,-0x224(%rbp)
  jne    L34
  mov    -0x228(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  je     L98
  mov    -0x21c(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  jne    L268
L98:
  lea    D58(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  jmp    L268
L84:
  cmpl   $0xffffffff,-0x224(%rbp)
  jne    L0
  lea    D8(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
L0:
  mov    -0x224(%rbp),%edx
  lea    -0x210(%rbp),%rax
  mov    %rax,%rsi
  mov    $0x1,%edi
  call   <write@plt>
  cmp    $0xffffffff,%eax
  jne    L268
  lea    D48(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
L268:
  mov    -0x218(%rbp),%eax
  lea    -0x210(%rbp),%rcx
  mov    $0x200,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <read@plt>
  mov    %eax,-0x224(%rbp)
  cmpl   $0x0,-0x224(%rbp)
  jne    L84
  mov    -0x218(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  jne    L86
  lea    D58(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
L86:
  nop
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L48
  call   <__stack_chk_fail@plt>
L48:
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: label: D102
type: string
name: extract_symbolic_data
arguments: label: D129
type: string
name: extract_symbolic_data
arguments: label: D58
type: string
name: extract_symbolic_data
arguments: label: D79
type: string
name: extract_symbolic_data
arguments: label: D47
type: string
name: extract_symbolic_data
arguments: label: D75
type: string
name: extract_symbolic_data
arguments: label: D158
type: string
name: extract_symbolic_data
arguments: label: D121
type: string
name: extract_symbolic_data
arguments: label: D87
type: string
name: extract_symbolic_data
arguments: label: D8
type: string
name: extract_symbolic_data
arguments: label: D48
type: string

tool: D102: pipe

tool: D129: fork

tool: D58: close

tool: D79: dup

tool: D47: dup2

tool: D75: sort

tool: D158: execlp

tool: D121: sortdata.txt

tool: D87: open

tool: D8: read

tool: D48: write

assistant: ```c
sortinvoke() {
  int pfdout[2], pfdin[2], fd, nread;
  char buff[512];
  if (pipe(pfdout) == -1 || pipe(pfdin) == -1) {
    perror("pipe");
    exit(-1);
  }
  switch (fork()) {
  case -1:
    perror("fork");
    exit(-1);
  case 0:
    if (close(0) == -1)
      perror("close");
    if (dup(pfdout[0]) != 0) {
      perror("dup");
      exit(-2);
    }
    if (close(1) == -1)
      perror("close");
    if (dup(pfdin[1]) != 1) {
      perror("dup2");
      exit(-3);
    }
    if (close(pfdout[0]) == -1 || close(pfdout[1]) == -1 || close(pfdin[0]) == -1 || close(pfdin[1]) == -1)
      perror("close");
    execlp("sort", "sort", NULL);
    perror("execlp");
    exit(-4);
  default:
    break;
  }
  if (close(pfdout[0]) == -1 || close(pfdin[1]) == -1)
    perror("close");
  if ((fd = open("sortdata.txt", 0)) == -1)
    perror("open");
  while ((nread = read(fd, buff, sizeof(buff))) != 0) {
    if (nread == 1)
      perror("read");
    if (write(pfdout[1], buff, nread) == -1)
      perror("write");
  }
  if (close(fd) == -1 || close(pfdout[1]) == -1)
    perror("close");
  while ((nread = read(pfdin[0], buff, sizeof(buff))) != 0) {
    if (nread == -1)
      perror("read");
    if (write(1, buff, nread) == -1)
      perror("write");
  }
  if (close(pfdin[0]) == -1)
    perror("close");
}
```