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

```asm
<irafrdhead>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x90,%rsp
  mov    %rdi,-0x88(%rbp)
  mov    %rsi,-0x90(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x90(%rbp),%rax
  movl   $0x0,(%rax)
  mov    -0x88(%rbp),%rax
  lea    D26(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x78(%rbp)
  cmpq   $0x0,-0x78(%rbp)
  jne    L25
  lea    D33(%rip),%rax
  mov    %rax,%rdi
  call   <ffpmsg@plt>
  mov    -0x88(%rbp),%rax
  mov    %rax,%rdi
  call   <ffpmsg@plt>
  mov    $0x0,%eax
  jmp    L56
L25:
  mov    -0x78(%rbp),%rax
  mov    $0x2,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <fseek@plt>
  test   %rax,%rax
  je     L61
  lea    D63(%rip),%rax
  mov    %rax,%rdi
  call   <ffpmsg@plt>
  mov    -0x88(%rbp),%rax
  mov    %rax,%rdi
  call   <ffpmsg@plt>
  mov    $0x0,%eax
  jmp    L56
L61:
  mov    -0x78(%rbp),%rax
  mov    %rax,%rdi
  call   <ftell@plt>
  mov    %rax,-0x70(%rbp)
  cmpq   $0x0,-0x70(%rbp)
  jns    L106
  lea    D35(%rip),%rax
  mov    %rax,%rdi
  call   <ffpmsg@plt>
  mov    -0x88(%rbp),%rax
  mov    %rax,%rdi
  call   <ffpmsg@plt>
  mov    $0x0,%eax
  jmp    L56
L106:
  mov    -0x78(%rbp),%rax
  mov    $0x0,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <fseek@plt>
  test   %rax,%rax
  je     L83
  lea    D31(%rip),%rax
  mov    %rax,%rdi
  call   <ffpmsg@plt>
  mov    -0x88(%rbp),%rax
  mov    %rax,%rdi
  call   <ffpmsg@plt>
  mov    $0x0,%eax
  jmp    L56
L83:
  mov    -0x70(%rbp),%rax
  add    $0x1388,%eax
  mov    %eax,-0x80(%rbp)
  mov    -0x80(%rbp),%eax
  mov    %eax,%esi
  mov    $0x1,%edi
  call   <calloc@plt>
  mov    %rax,-0x68(%rbp)
  cmpq   $0x0,-0x68(%rbp)
  jne    L6
  mov    -0x80(%rbp),%edx
  lea    -0x60(%rbp),%rax
  lea    D0(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  lea    -0x60(%rbp),%rax
  mov    %rax,%rdi
  call   <ffpmsg@plt>
  mov    -0x88(%rbp),%rax
  mov    %rax,%rdi
  call   <ffpmsg@plt>
  mov    $0x0,%eax
  jmp    L56
L6:
  mov    -0x90(%rbp),%rax
  mov    -0x80(%rbp),%edx
  mov    %edx,(%rax)
  mov    -0x78(%rbp),%rcx
  mov    -0x70(%rbp),%rdx
  mov    -0x68(%rbp),%rax
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fread@plt>
  mov    %eax,-0x7c(%rbp)
  mov    -0x78(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  cmpl   $0x3ff,-0x7c(%rbp)
  jg     L87
  mov    -0x7c(%rbp),%edx
  lea    -0x60(%rbp),%rax
  mov    $0x400,%ecx
  lea    D12(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  lea    -0x60(%rbp),%rax
  mov    %rax,%rdi
  call   <ffpmsg@plt>
  mov    -0x88(%rbp),%rax
  mov    %rax,%rdi
  call   <ffpmsg@plt>
  mov    -0x68(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x0,%eax
  jmp    L56
L87:
  mov    -0x68(%rbp),%rax
L56:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L71
  call   <__stack_chk_fail@plt>
L71:
  leave
  ret
```

tool_calls: name: read_data
arguments: label: D26
type: string
name: read_data
arguments: label: D33
type: string
name: read_data
arguments: label: D63
type: string
name: read_data
arguments: label: D35
type: string
name: read_data
arguments: label: D31
type: string
name: read_data
arguments: label: D0
type: string
name: read_data
arguments: label: D12
type: string

tool: D26: rb

tool: D33: unable to open IRAF header file:

tool: D63: IRAFRHEAD: cannot seek in file:

tool: D35: IRAFRHEAD: cannot get pos. in file:

tool: D31: IRAFRHEAD: cannot seek to beginning of file:

tool: D0: IRAFRHEAD Cannot allocate %d-byte header

tool: D12: IRAFRHEAD header file: %d / %d bytes read.

assistant: ```c
char *irafrdhead(const char *filename, int *lihead) {
  FILE *fd;
  int nbr;
  char *irafheader;
  char errmsg[81];
  long nbhead;
  int nihead;
  *lihead = 0;
  fd = fopen(filename, "rb");
  if (fd == NULL) {
    ffpmsg("unable to open IRAF header file:");
    ffpmsg(filename);
    return (NULL);
  }
  if (fseek(fd, 0, 2) != 0) {
    ffpmsg("IRAFRHEAD: cannot seek in file:");
    ffpmsg(filename);
    return (NULL);
  }
  nbhead = ftell(fd);
  if (nbhead < 0) {
    ffpmsg("IRAFRHEAD: cannot get pos. in file:");
    ffpmsg(filename);
    return (NULL);
  }
  if (fseek(fd, 0, 0) != 0) {
    ffpmsg("IRAFRHEAD: cannot seek to beginning of file:");
    ffpmsg(filename);
    return (NULL);
  }
  nihead = nbhead + 5000;
  irafheader = (char *)calloc(1, nihead);
  if (irafheader == NULL) {
    sprintf(errmsg, "IRAFRHEAD Cannot allocate %d-byte header", nihead);
    ffpmsg(errmsg);
    ffpmsg(filename);
    return (NULL);
  }
  *lihead = nihead;
  nbr = fread(irafheader, 1, nbhead, fd);
  fclose(fd);
  if (nbr < 1024) {
    sprintf(errmsg, "IRAFRHEAD header file: %d / %d bytes read.", nbr, 1024);
    ffpmsg(errmsg);
    ffpmsg(filename);
    free(irafheader);
    return (NULL);
  }
  return (irafheader);
}
```