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

```asm
<qfits_getkey>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbx
  test   %rdi,%rdi
  je     L44
  mov    $0x8,%edx
  lea    D97(%rip),%rsi
  call   <strncmp@plt>
  test   %eax,%eax
  je     L57
  mov    $0x8,%edx
  lea    D118(%rip),%rsi
  mov    %rbx,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  je     L1
  mov    $0x8,%edx
  lea    D76(%rip),%rsi
  mov    %rbx,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  je     L161
  mov    $0x4,%edx
  lea    D47(%rip),%rsi
  mov    %rbx,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  je     L20
  mov    $0x51,%edx
  mov    $0x0,%esi
  lea    D2(%rip),%rdi
  call   <memset@plt>
  cmpb   $0x3d,(%rbx)
  je     L113
  mov    $0x1,%eax
L23:
  mov    %eax,%edx
  cmpb   $0x3d,(%rbx,%rax,1)
  setne  %sil
  cmp    $0x4f,%eax
  setle  %cl
  add    $0x1,%rax
  test   %cl,%sil
  jne    L23
  cmp    $0x4f,%edx
  jg     L69
  lea    -0x1(%rdx),%ebp
  movslq %ebp,%rax
  cmpb   $0x20,(%rbx,%rax,1)
  jne    L144
  test   %ebp,%ebp
  js     L144
  lea    -0x2(%rdx),%eax
  cltq
L52:
  mov    %eax,%ebp
  cmpb   $0x20,(%rbx,%rax,1)
  sete   %cl
  mov    %eax,%edx
  not    %edx
  shr    $0x1f,%edx
  sub    $0x1,%rax
  test   %dl,%cl
  jne    L52
L144:
  mov    $0x0,%eax
  test   %ebp,%ebp
  jle    L111
  lea    0x1(%rbp),%edx
  mov    %rbx,%rsi
  lea    D2(%rip),%rbx
  mov    %rbx,%rdi
  call   <strncpy@plt>
  add    $0x2,%ebp
  movslq %ebp,%rbp
  movb   $0x0,(%rbx,%rbp,1)
  mov    %rbx,%rax
  jmp    L111
L57:
  lea    D97(%rip),%rsi
  lea    D2(%rip),%rbx
  mov    %rbx,%rdi
  call   <strcpy@plt>
  mov    %rbx,%rax
L111:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L1:
  lea    D7(%rip),%rsi
  lea    D2(%rip),%rbx
  mov    %rbx,%rdi
  call   <strcpy@plt>
  mov    %rbx,%rax
  jmp    L111
L161:
  lea    D100(%rip),%rsi
  lea    D2(%rip),%rbx
  mov    %rbx,%rdi
  call   <strcpy@plt>
  mov    %rbx,%rax
  jmp    L111
L20:
  lea    D79(%rip),%rsi
  lea    D2(%rip),%rbx
  mov    %rbx,%rdi
  call   <strcpy@plt>
  mov    %rbx,%rax
  jmp    L111
L113:
  mov    $0xffffffff,%ebp
  jmp    L144
L44:
  mov    %rdi,%rax
  jmp    L111
L69:
  mov    $0x0,%eax
  jmp    L111
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D97
datatype: string
name: extract_symbolic_data
arguments: data_tag: D118
datatype: string
name: extract_symbolic_data
arguments: data_tag: D76
datatype: string
name: extract_symbolic_data
arguments: data_tag: D47
datatype: string
name: extract_symbolic_data
arguments: data_tag: D7
datatype: string
name: extract_symbolic_data
arguments: data_tag: D100
datatype: string
name: extract_symbolic_data
arguments: data_tag: D79
datatype: string

tool: D97:         

tool: D118: HISTORY 

tool: D76: COMMENT 

tool: D47: END 

tool: D7: HISTORY

tool: D100: COMMENT

tool: D79: END

assistant: ```c
char *qfits_getkey(const char *line) {
  static char key[81];
  int i;
  if (line == NULL) {
    return NULL;
  }
  if (!strncmp(line, "        ", 8)) {
    strcpy(key, "        ");
    return key;
  }
  if (!strncmp(line, "HISTORY ", 8)) {
    strcpy(key, "HISTORY");
    return key;
  }
  if (!strncmp(line, "COMMENT ", 8)) {
    strcpy(key, "COMMENT");
    return key;
  }
  if (!strncmp(line, "END ", 4)) {
    strcpy(key, "END");
    return key;
  }
  memset(key, 0, 81);
  i = 0;
  while (line[i] != '=' && i < 80)
    i++;
  if (i >= 80) {
    return NULL;
  }
  i--;
  while (line[i] == ' ' && i >= 0)
    i--;
  if (i <= 0) {
    return NULL;
  }
  i++;
  strncpy(key, line, i);
  key[i + 1] = (char)0;
  return key;
}
```