user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<rdhdr_c>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0xd8,%rsp
  mov    %rdi,-0xb8(%rbp)
  mov    %rsi,-0xc0(%rbp)
  mov    %edx,-0xc4(%rbp)
  mov    %ecx,-0xc8(%rbp)
  mov    %r8,-0xd0(%rbp)
  mov    %r9,-0xd8(%rbp)
  mov    0x10(%rbp),%rax
  mov    %rax,-0xe0(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  mov    $0x0,%ebx
  cmpl   $0x0,-0xc4(%rbp)
  jle    L118
  mov    -0xb8(%rbp),%rax
  mov    %rax,-0xb0(%rbp)
  mov    -0xc4(%rbp),%eax
  movslq %eax,%rdx
  imul   $0x68db8bad,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0xc,%edx
  sar    $0x1f,%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  add    $0x30,%eax
  addq   $0x1,-0xb0(%rbp)
  mov    %eax,%edx
  mov    -0xb0(%rbp),%rax
  mov    %dl,(%rax)
  mov    -0xc4(%rbp),%edx
  movslq %edx,%rax
  imul   $0x68db8bad,%rax,%rax
  shr    $0x20,%rax
  sar    $0xc,%eax
  mov    %edx,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%eax
  imul   $0x2710,%eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  movslq %eax,%rdx
  imul   $0x10624dd3,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x6,%edx
  sar    $0x1f,%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  add    $0x30,%eax
  addq   $0x1,-0xb0(%rbp)
  mov    %eax,%edx
  mov    -0xb0(%rbp),%rax
  mov    %dl,(%rax)
L118:
  mov    -0xb8(%rbp),%rax
  lea    D2(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fopen@plt>
  mov    %rax,-0xa8(%rbp)
  cmpq   $0x0,-0xa8(%rbp)
  jne    L32
  mov    $0x0,%eax
  jmp    L96
L32:
  mov    -0xa8(%rbp),%rdx
  lea    -0xa0(%rbp),%rax
  mov    $0x78,%esi
  mov    %rax,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  jne    L98
  mov    $0x0,%eax
  jmp    L96
L98:
  mov    -0xa8(%rbp),%rdx
  lea    -0xa0(%rbp),%rax
  mov    $0x78,%esi
  mov    %rax,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  jne    L101
  mov    $0x0,%eax
  jmp    L96
L101:
  mov    -0xa8(%rbp),%rdx
  lea    -0xa0(%rbp),%rax
  mov    $0x78,%esi
  mov    %rax,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  jne    L21
  mov    $0x0,%eax
  jmp    L96
L21:
  mov    -0xe0(%rbp),%rsi
  mov    -0xd8(%rbp),%rcx
  mov    -0xd0(%rbp),%rdx
  lea    -0xa0(%rbp),%rax
  mov    %rsi,%r8
  lea    D4(%rip),%rsi
  mov    %rax,%rdi
  call   <sscanf@plt>
  cmp    $0x3,%eax
  je     L25
  mov    $0x0,%eax
  jmp    L96
L25:
  mov    -0xa8(%rbp),%rdx
  mov    -0xc0(%rbp),%rax
  mov    $0x78,%esi
  mov    %rax,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  jne    L39
  mov    $0x0,%eax
  jmp    L96
L39:
  add    $0x1,%ebx
  cmp    -0xc8(%rbp),%ebx
  jl     L101
  mov    -0xc0(%rbp),%rax
  add    $0xa,%rax
  movb   $0x0,(%rax)
  mov    -0xa8(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    $0x1,%eax
L96:
  mov    -0x18(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L104
  call   <__stack_chk_fail@plt>
L104:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_label: D2
type_infered: string
name: unpack_data
arguments: data_label: D4
type_infered: string

tool: D2: r

tool: D4: %8d%8d%8d

assistant: ```c
int rdhdr_c(char *filename, char *binary, int ispec, int filenum, int *npix, int *nrast, int *nframe) {
  char buff[120 + 1], *cptr;
  register int i = 0;
  FILE *fp, *fopen();
  if (ispec > 0) {
    cptr = filename;
    *++cptr = (ispec / 10000) + '0';
    *++cptr = ((ispec % 10000) / 1000) + '0';
  }
  if ((fp = fopen(filename, "r")) == NULL)
    return (0);
  else {
    if ((fgets(buff, 120, fp)) == NULL)
      return (0);
    else if ((fgets(buff, 120, fp)) == NULL)
      return (0);
    else {
      do {
        if ((fgets(buff, 120, fp)) == NULL)
          return (0);
        else if (sscanf(buff, "%8d%8d%8d", npix, nrast, nframe) != 3)
          return (0);
        else if ((fgets(binary, 120, fp)) == NULL)
          return (0);
      } while (++i < filenum);
    }
    *(binary + 10) = '\0';
    fclose(fp);
    return (!0);
  }
}
```