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

```asm
<get_swap_info>:
  endbr64
  push   %r15
  push   %r14
  lea    D85(%rip),%r14
  push   %r13
  lea    D109(%rip),%r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,0x18(%rsp)
  mov    %rsi,0x8(%rsp)
  mov    %rdx,0x10(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  xor    %eax,%eax
  test   %rdi,%rdi
  lea    D20(%rip),%rdi
  movq   $0x0,0x28(%rsp)
  setne  %al
  cmp    $0x1,%rsi
  lea    D83(%rip),%rsi
  movq   $0x0,0x30(%rsp)
  sbb    $0xffffffffffffffff,%rax
  cmp    $0x1,%rdx
  sbb    $0xffffffffffffffff,%rax
  mov    %rax,(%rsp)
  call   <fopen@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L375
L391:
  cmpq   $0x0,(%rsp)
  je     L224
  cmpq   $0x0,0x10(%rsp)
  lea    0x28(%rsp),%r12
  lea    0x30(%rsp),%rbx
  je     L115
  cmpq   $0x0,0x8(%rsp)
  je     L186
  cmpq   $0x0,0x18(%rsp)
  je     L151
L2:
  mov    %rbp,%rdx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <getline@plt>
  test   %rax,%rax
  js     L224
  mov    0x30(%rsp),%r15
  mov    $0x9,%edx
  mov    %r13,%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  je     L263
  mov    $0x8,%edx
  mov    %r14,%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  je     L320
  mov    $0xa,%edx
  lea    D9(%rip),%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L2
L97:
  mov    0x10(%rsp),%rdx
  mov    $0xb,%edi
L377:
  add    %r15,%rdi
  lea    D28(%rip),%rsi
  call   <sscanf@plt>
  subq   $0x1,(%rsp)
  jmp    L391
  nopl   0x0(%rax)
L151:
  mov    %rbp,%rdx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <getline@plt>
  test   %rax,%rax
  js     L224
  mov    0x30(%rsp),%r15
  mov    $0x8,%edx
  mov    %r14,%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  je     L320
  mov    $0xa,%edx
  lea    D9(%rip),%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L151
  jmp    L97
L33:
  mov    %rbp,%rdx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <getline@plt>
  test   %rax,%rax
  jns    L33
  nopl   (%rax)
L224:
  mov    0x30(%rsp),%rdi
  call   <free@plt>
  mov    %rbp,%rdi
  call   <ferror@plt>
  test   %rax,%rax
  jne    L128
  mov    %rbp,%rdi
  call   <fclose@plt>
  xor    %eax,%eax
L255:
  mov    0x38(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L251
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L115:
  cmpq   $0x0,0x8(%rsp)
  je     L114
  cmpq   $0x0,0x18(%rsp)
  je     L226
L166:
  mov    %rbp,%rdx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <getline@plt>
  test   %rax,%rax
  js     L224
  mov    0x30(%rsp),%r15
  mov    $0x9,%edx
  mov    %r13,%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  je     L263
  mov    $0x8,%edx
  mov    %r14,%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L166
L320:
  mov    0x8(%rsp),%rdx
  mov    $0x9,%edi
  jmp    L377
  nopw   0x0(%rax,%rax,1)
L226:
  mov    %rbp,%rdx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <getline@plt>
  test   %rax,%rax
  js     L224
  mov    0x30(%rsp),%r15
  mov    $0x8,%edx
  mov    %r14,%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L226
  jmp    L320
  nopw   0x0(%rax,%rax,1)
L186:
  cmpq   $0x0,0x18(%rsp)
  je     L358
L134:
  mov    %rbp,%rdx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <getline@plt>
  test   %rax,%rax
  js     L224
  mov    0x30(%rsp),%r15
  mov    $0x9,%edx
  mov    %r13,%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  je     L263
  mov    $0xa,%edx
  lea    D9(%rip),%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L134
  jmp    L97
  nopl   0x0(%rax)
L358:
  mov    %rbp,%rdx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <getline@plt>
  test   %rax,%rax
  js     L224
  mov    0x30(%rsp),%r15
  mov    $0xa,%edx
  lea    D9(%rip),%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L358
  jmp    L97
L114:
  cmpq   $0x0,0x18(%rsp)
  je     L33
L43:
  mov    %rbp,%rdx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <getline@plt>
  test   %rax,%rax
  js     L224
  mov    0x30(%rsp),%r15
  mov    $0x9,%edx
  mov    %r13,%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L43
L263:
  mov    0x18(%rsp),%rdx
  mov    $0xa,%edi
  jmp    L377
L128:
  lea    D35(%rip),%rdi
  call   <warn@plt>
  mov    $0x1,%eax
  jmp    L255
L375:
  lea    D0(%rip),%rdi
  call   <warn@plt>
  mov    $0x1,%eax
  jmp    L255
L251:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: label: D85
type: string
name: unpack_data
arguments: label: D109
type: string
name: unpack_data
arguments: label: D20
type: string
name: unpack_data
arguments: label: D83
type: string
name: unpack_data
arguments: label: D9
type: string
name: unpack_data
arguments: label: D28
type: string
name: unpack_data
arguments: label: D35
type: string
name: unpack_data
arguments: label: D0
type: string

tool: D85: SwapFree

tool: D109: SwapTotal

tool: D20: /proc/meminfo

tool: D83: r

tool: D9: SwapCached

tool: D28: %ld kB


tool: D35: getline '/proc/meminfo':

tool: D0: fopen '/proc/meminfo':

assistant: ```c
int get_swap_info(long *s_total, long *s_free, long *s_cached) {
  FILE *fp;
  struct {
    const char *name;
    const size_t len;
    long *var;
  } ent[] = {
      {"SwapTotal", sizeof("SwapTotal") - 1, s_total},
      {"SwapFree", sizeof("SwapFree") - 1, s_free},
      {"SwapCached", sizeof("SwapCached") - 1, s_cached},
  };
  size_t line_len = 0, i, left;
  char *line = NULL;
  for (i = 0, left = 0; i < (sizeof(ent) / sizeof *(ent)); i++) {
    if (ent[i].var) {
      left++;
    }
  }
  if (!(fp = fopen("/proc/meminfo", "r"))) {
    warn("fopen '/proc/meminfo':");
    return 1;
  }
  while (left > 0 && getline(&line, &line_len, fp) >= 0) {
    for (i = 0; i < (sizeof(ent) / sizeof *(ent)); i++) {
      if (ent[i].var && !strncmp(line, ent[i].name, ent[i].len)) {
        sscanf(line + ent[i].len + 1, "%ld kB\n", ent[i].var);
        left--;
        break;
      }
    }
  }
  free(line);
  if (ferror(fp)) {
    warn("getline '/proc/meminfo':");
    return 1;
  }
  fclose(fp);
  return 0;
}
```