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

```asm
<sortinvoke>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x220,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x218(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rdi
  call   <pipe@plt>
  cmp    $0xffffffff,%eax
  je     L304
  lea    0x8(%rsp),%rdi
  call   <pipe@plt>
  cmp    $0xffffffff,%eax
  jne    L11
L304:
  lea    D128(%rip),%rdi
  call   <perror@plt>
  mov    $0xffffffff,%edi
  call   <exit@plt>
L11:
  call   <fork@plt>
  cmp    $0xffffffff,%eax
  je     L127
  test   %eax,%eax
  jne    L175
L202:
  mov    $0x0,%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  je     L357
L94:
  mov    (%rsp),%edi
  call   <dup@plt>
  test   %eax,%eax
  jne    L69
L142:
  mov    $0x1,%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  je     L366
L325:
  mov    0xc(%rsp),%edi
  call   <dup@plt>
  cmp    $0x1,%eax
  jne    L159
L313:
  mov    (%rsp),%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  je     L286
  mov    0x4(%rsp),%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  jne    L61
L286:
  lea    D36(%rip),%rdi
  call   <perror@plt>
L369:
  mov    $0x0,%edx
  lea    D30(%rip),%rdi
  mov    %rdi,%rsi
  call   <execlp@plt>
  lea    D29(%rip),%rdi
  call   <perror@plt>
  mov    $0xfffffffc,%edi
  call   <exit@plt>
L175:
  mov    (%rsp),%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  je     L158
  mov    0xc(%rsp),%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  jne    L27
L158:
  lea    D36(%rip),%rdi
  call   <perror@plt>
L27:
  mov    $0x0,%esi
  lea    D21(%rip),%rdi
  call   <open@plt>
  mov    %eax,%r12d
  cmp    $0xffffffff,%eax
  je     L12
L343:
  lea    D61(%rip),%r13
  lea    0x10(%rsp),%rbp
  lea    D43(%rip),%r14
  jmp    L42
L127:
  lea    D94(%rip),%rdi
  call   <perror@plt>
  mov    $0xffffffff,%edi
  call   <exit@plt>
  jmp    L202
L357:
  lea    D36(%rip),%rdi
  call   <perror@plt>
  jmp    L94
L69:
  lea    D170(%rip),%rdi
  call   <perror@plt>
  mov    $0xfffffffe,%edi
  call   <exit@plt>
  jmp    L142
L366:
  lea    D36(%rip),%rdi
  call   <perror@plt>
  jmp    L325
L159:
  lea    D52(%rip),%rdi
  call   <perror@plt>
  mov    $0xfffffffd,%edi
  call   <exit@plt>
  jmp    L313
L61:
  mov    0x8(%rsp),%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  je     L286
  mov    0xc(%rsp),%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  jne    L369
  jmp    L286
L12:
  lea    D145(%rip),%rdi
  call   <perror@plt>
  jmp    L343
L183:
  mov    %ebx,%edx
  mov    %rbp,%rsi
  mov    0x4(%rsp),%edi
  call   <write@plt>
  cmp    $0xffffffff,%eax
  je     L347
L42:
  mov    $0x200,%edx
  mov    %rbp,%rsi
  mov    %r12d,%edi
  call   <read@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  je     L211
  cmp    $0x1,%ebx
  jne    L183
  mov    %r13,%rdi
  call   <perror@plt>
  jmp    L183
L347:
  mov    %r14,%rdi
  call   <perror@plt>
  jmp    L42
L211:
  mov    %r12d,%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  je     L207
  mov    0x4(%rsp),%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  jne    L283
L207:
  lea    D36(%rip),%rdi
  call   <perror@plt>
L283:
  lea    D61(%rip),%r12
  lea    0x10(%rsp),%rbp
  lea    D43(%rip),%r13
  jmp    L353
L85:
  mov    %ebx,%edx
  mov    %rbp,%rsi
  mov    $0x1,%edi
  call   <write@plt>
  cmp    $0xffffffff,%eax
  je     L91
L353:
  mov    $0x200,%edx
  mov    %rbp,%rsi
  mov    0x8(%rsp),%edi
  call   <read@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  je     L237
  cmp    $0xffffffff,%ebx
  jne    L85
  mov    %r12,%rdi
  call   <perror@plt>
  jmp    L85
L91:
  mov    %r13,%rdi
  call   <perror@plt>
  jmp    L353
L237:
  mov    0x8(%rsp),%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  je     L149
L223:
  mov    0x218(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L120
  mov    $0x0,%eax
  add    $0x220,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L149:
  lea    D36(%rip),%rdi
  call   <perror@plt>
  jmp    L223
L120:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D128
data_type: string
name: extract_symbolic_data
arguments: data_label: D36
data_type: string
name: extract_symbolic_data
arguments: data_label: D30
data_type: string
name: extract_symbolic_data
arguments: data_label: D29
data_type: string
name: extract_symbolic_data
arguments: data_label: D21
data_type: string
name: extract_symbolic_data
arguments: data_label: D61
data_type: string
name: extract_symbolic_data
arguments: data_label: D43
data_type: string
name: extract_symbolic_data
arguments: data_label: D94
data_type: string
name: extract_symbolic_data
arguments: data_label: D170
data_type: string
name: extract_symbolic_data
arguments: data_label: D52
data_type: string
name: extract_symbolic_data
arguments: data_label: D145
data_type: string

tool: D128: pipe

tool: D36: close

tool: D30: sort

tool: D29: execlp

tool: D21: sortdata.txt

tool: D61: read

tool: D43: write

tool: D94: fork

tool: D170: dup

tool: D52: dup2

tool: D145: open

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");
}
```