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

```asm
<getmeminfo>:
  endbr64
  push   %r15
  lea    D0(%rip),%r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x4c8,%rsp
  mov    %rdi,0x18(%rsp)
  lea    0xb0(%rsp),%rbx
  mov    %rsi,0x8(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x4b8(%rsp)
  xor    %eax,%eax
  movl   $0x0,(%rdi)
  lea    D34(%rip),%rdi
  movl   $0x0,(%rsi)
  lea    D5(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%r14
  jmp    L33
  nopl   (%rax)
L91:
  mov    %rbp,%rsi
  lea    D22(%rip),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L67
L8:
  mov    %rbp,%rsi
  lea    D47(%rip),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L4
L75:
  mov    %rbp,%rsi
  lea    D48(%rip),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L39
L33:
  mov    %r14,%rdx
  mov    $0x400,%esi
  mov    %rbx,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  je     L22
  lea    0x30(%rsp),%rbp
  lea    0x28(%rsp),%r12
  mov    %rbx,%rdi
  movb   $0x0,0x30(%rsp)
  lea    0x70(%rsp),%r13
  mov    %r12,%r8
  mov    %rbp,%rdx
  movb   $0x0,0x70(%rsp)
  lea    D46(%rip),%rsi
  mov    %r13,%rcx
  movb   $0x0,0x28(%rsp)
  call   <sscanf@plt>
  mov    %rbp,%rsi
  lea    D23(%rip),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L91
  mov    %r13,%rdi
  call   <atoi@plt>
  mov    %r12,%rsi
  mov    %r15,%rdi
  mov    %eax,0x14(%rsp)
  call   <strcmp@plt>
  mov    0x14(%rsp),%edx
  mov    %rax,%r8
  mov    %edx,%eax
  shl    $0xa,%eax
  test   %r8,%r8
  cmove  %eax,%edx
  mov    0x18(%rsp),%rax
  mov    %edx,(%rax)
  jmp    L91
  nopl   0x0(%rax)
L4:
  mov    %r13,%rdi
  call   <atoi@plt>
  mov    %r12,%rsi
  mov    %r15,%rdi
  mov    %eax,0x14(%rsp)
  call   <strcmp@plt>
  mov    0x14(%rsp),%edx
  mov    %rax,%r8
  mov    %edx,%eax
  shl    $0xa,%eax
  test   %r8,%r8
  cmove  %eax,%edx
  mov    0x8(%rsp),%rax
  add    %edx,(%rax)
  jmp    L75
  nopl   (%rax)
L67:
  mov    %r13,%rdi
  call   <atoi@plt>
  mov    %r12,%rsi
  mov    %r15,%rdi
  mov    %eax,0x14(%rsp)
  call   <strcmp@plt>
  mov    0x14(%rsp),%edx
  mov    %rax,%r8
  mov    %edx,%eax
  shl    $0xa,%eax
  test   %r8,%r8
  cmove  %eax,%edx
  mov    0x8(%rsp),%rax
  add    %edx,(%rax)
  jmp    L8
  nopl   (%rax)
L22:
  mov    %r14,%rdi
  call   <fclose@plt>
  mov    0x4b8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L106
  add    $0x4c8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L39:
  mov    %r13,%rdi
  call   <atoi@plt>
  mov    %r12,%rsi
  mov    %r15,%rdi
  mov    %eax,%ebp
  call   <strcmp@plt>
  mov    %rax,%r8
  mov    %ebp,%eax
  shl    $0xa,%eax
  test   %r8,%r8
  cmove  %eax,%ebp
  mov    0x8(%rsp),%rax
  add    %ebp,(%rax)
  jmp    L33
L106:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D0
type: string
name: read_data
arguments: tag: D34
type: string
name: read_data
arguments: tag: D5
type: string
name: read_data
arguments: tag: D22
type: string
name: read_data
arguments: tag: D47
type: string
name: read_data
arguments: tag: D48
type: string
name: read_data
arguments: tag: D46
type: string
name: read_data
arguments: tag: D23
type: string

tool: D0: kB

tool: D34: /proc/meminfo

tool: D5: r

tool: D22: MemFree:

tool: D47: Buffers:

tool: D48: Cached:

tool: D46: %s%s%s

tool: D23: MemTotal:

assistant: ```c
int getmeminfo(uint64_t *size, uint64_t *free) {
  FILE *f;
  char key[64];
  char val[64];
  char unit[8];
  char buff[1024];
  uint64_t data;
  *size = 0;
  *free = 0;
  f = fopen("/proc/meminfo", "r");
  while (fgets(buff, sizeof(buff), f)) {
    key[0] = 0;
    val[0] = 0;
    unit[0] = 0;
    sscanf(buff, "%s%s%s", key, val, unit);
    if (strcmp("MemTotal:", key) == 0) {
      data = atoi(val);
      if (strcmp("kB", unit) == 0) {
        data *= 1024;
      }
      *size = data;
    }
    if (strcmp("MemFree:", key) == 0) {
      data = atoi(val);
      if (strcmp("kB", unit) == 0) {
        data *= 1024;
      }
      *free += data;
    }
    if (strcmp("Buffers:", key) == 0) {
      data = atoi(val);
      if (strcmp("kB", unit) == 0) {
        data *= 1024;
      }
      *free += data;
    }
    if (strcmp("Cached:", key) == 0) {
      data = atoi(val);
      if (strcmp("kB", unit) == 0) {
        data *= 1024;
      }
      *free += data;
    }
  }
  fclose(f);
  return (0);
}
```