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

```asm
<memd>:
  endbr64
  push   %r15
  lea    D27(%rip),%rdi
  lea    D28(%rip),%r15
  push   %r14
  push   %r13
  xor    %r13d,%r13d
  push   %r12
  push   %rbp
  push   %rbx
  xor    %ebx,%ebx
  sub    $0x128,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x118(%rsp)
  xor    %eax,%eax
  lea    0x10(%rsp),%rbp
  call   <puts0@plt>
  lea    0x12(%rsp),%rax
  movb   $0x4d,0x7(%rsp)
  mov    %rax,0x8(%rsp)
  nopl   0x0(%rax)
L307:
  mov    %ebx,%edi
  call   <puthex@plt>
  mov    $0x3a,%edi
  call   <putch@plt>
  mov    %r13d,%edi
  call   <puthex@plt>
  mov    $0x20,%edi
  call   <putch@plt>
  cmpb   $0x41,0x7(%rsp)
  je     L230
  cmpb   $0x4d,0x7(%rsp)
  je     L65
  cmpb   $0x48,0x7(%rsp)
  je     L67
L60:
  mov    %r15,%rdi
  call   <puts0@plt>
  mov    $0x3a,%edi
  call   <putch@plt>
  mov    $0x100,%esi
  mov    %rbp,%rdi
  call   <getsn@plt>
  movzbl 0x10(%rsp),%esi
  xor    %eax,%eax
  mov    %esi,%edx
  test   %sil,%sil
  jne    L145
  jmp    L247
  nopl   0x0(%rax,%rax,1)
L159:
  add    $0x1,%rax
  movzbl 0x0(%rbp,%rax,1),%edx
  test   %dl,%dl
  je     L293
L145:
  movslq %eax,%rcx
  cmp    $0xd,%dl
  jne    L159
  movb   $0x0,0x10(%rsp,%rcx,1)
  movzbl 0x10(%rsp),%eax
  cmp    $0x2f,%al
  je     L42
  test   %al,%al
  jne    L307
L247:
  add    $0x10,%r13d
  jmp    L307
  nopl   0x0(%rax)
L293:
  cmp    $0x2f,%sil
  jne    L307
L42:
  movsbl 0x11(%rsp),%edi
  call   <toupper@plt>
  cmp    $0x51,%al
  je     L66
  lea    -0x3f(%rax),%edx
  cmp    $0x1b,%dl
  ja     L140
  lea    D41(%rip),%rcx
  movzbl %dl,%edx
  movslq (%rcx,%rdx,4),%rdx
  add    %rcx,%rdx
  notrack jmp *%rdx
L140:
  lea    D8(%rip),%rdi
  call   <puts0@plt>
  nopl   0x0(%rax)
L272:
  mov    %r15,%rdi
  call   <puts0@plt>
  jmp    L307
  mov    %al,0x7(%rsp)
  jmp    L272
  lea    D40(%rip),%rdi
  call   <puts0@plt>
  jmp    L272
  mov    0x8(%rsp),%rdi
  call   <htoi@plt>
  mov    %r13d,%edx
  mov    %ebx,%esi
  mov    %eax,%edi
  call   <poke@plt>
  jmp    L272
  xor    %eax,%eax
  call   <memmap@plt>
  jmp    L272
  mov    0x8(%rsp),%rdi
  call   <htoi@plt>
  mov    %eax,%ebx
  jmp    L272
  mov    0x8(%rsp),%rdi
  call   <htoi@plt>
  mov    %eax,%r13d
  jmp    L272
  nop
L230:
  lea    0x10(%r13),%r12d
  mov    %r13d,%r14d
  jmp    L164
  nopl   0x0(%rax)
L275:
  movsbl %al,%edi
  call   <putch@plt>
L295:
  add    $0x1,%r14d
  cmp    %r12d,%r14d
  je     L60
L164:
  mov    %r14d,%esi
  mov    %ebx,%edi
  call   <peek3@plt>
  cmp    $0x1f,%al
  jg     L275
  mov    $0x2e,%edi
  call   <putch@plt>
  jmp    L295
  nop
L65:
  lea    0x10(%r13),%r12d
  mov    %r13d,%r14d
  nopw   0x0(%rax,%rax,1)
L52:
  mov    %r14d,%esi
  mov    %ebx,%edi
  add    $0x1,%r14d
  call   <peek3@plt>
  movsbl %al,%edi
  call   <puthex_b@plt>
  mov    $0x20,%edi
  call   <putch@plt>
  cmp    %r14d,%r12d
  jne    L52
  mov    %r13d,%r14d
  jmp    L16
  nopw   0x0(%rax,%rax,1)
L245:
  movsbl %al,%edi
  call   <putch@plt>
L305:
  add    $0x1,%r14d
  cmp    %r12d,%r14d
  je     L60
L16:
  mov    %r14d,%esi
  mov    %ebx,%edi
  call   <peek3@plt>
  cmp    $0x1f,%al
  jg     L245
  mov    $0x2e,%edi
  call   <putch@plt>
  jmp    L305
  nop
L67:
  lea    0x10(%r13),%r14d
  mov    %r13d,%r12d
  nopw   0x0(%rax,%rax,1)
L260:
  mov    %r12d,%esi
  mov    %ebx,%edi
  add    $0x1,%r12d
  call   <peek3@plt>
  movsbl %al,%edi
  call   <puthex_b@plt>
  mov    $0x20,%edi
  call   <putch@plt>
  cmp    %r12d,%r14d
  jne    L260
  jmp    L60
L66:
  mov    %r15,%rdi
  call   <puts0@plt>
  mov    0x118(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L161
  add    $0x128,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L161:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: data_label: D27
type_infered: string
name: parse_data
arguments: data_label: D28
type_infered: string
name: parse_data
arguments: data_label: D8
type_infered: string
name: parse_data
arguments: data_label: D40
type_infered: string

tool: D27: Use /? command for help


tool: D28: 


tool: D8: Invalid command


tool: D40: Commands:
/Q - Quit
/A - Ascii mode
/H - Hex mode
/M - Mix (hex & ascii) mode
/S<hex_value> - set Segment
/O<hex_value> - set Offset
/K - print memory map
Enter - next string
/Z<hex_value> - poke hex_value to memory


assistant: ```c
void memd(void) {
  char c;
  int i;
  char Option = 'M';
  unsigned int segm, off;
  char cmd[256];
  segm = 0;
  off = 0;
  puts0("Use /? command for help\r\n");
  while (1) {
    puthex(segm);
    putch(':');
    puthex(off);
    putch(' ');
    {
      if (Option == 'A') {
        for (i = 0; i < 16; i++) {
          if ((c = peek3(segm, (off + i))) >= ' ')
            putch(c);
          else
            putch('.');
        }
      } else if (Option == 'M') {
        for (i = 0; i < 16; i++) {
          puthex_b(peek3(segm, (off + i)));
          putch(' ');
        }
        for (i = 0; i < 16; i++) {
          if ((c = peek3(segm, (off + i))) >= ' ')
            putch(c);
          else
            putch('.');
        }
      } else if (Option == 'H') {
        for (i = 0; i < 16; i++) {
          puthex_b(peek3(segm, (off + i)));
          putch(' ');
        }
      }
    }
    puts0("\r\n");
    putch(':');
    getsn(cmd, 256);
    i = 0;
    while (cmd[i])
      if (cmd[i] == '\r') {
        cmd[i] = 0;
        break;
      } else
        i++;
    if (cmd[0] == '/') {
      c = toupper(cmd[1]);
      {
        if (c == 'Q') {
          puts0("\r\n");
          return;
        } else if ((c == 'A') || (c == 'H') || (c == 'M'))
          Option = c;
        else if (c == 'S')
          segm = htoi(cmd + 2);
        else if (c == 'O')
          off = htoi(cmd + 2);
        else if (c == 'K')
          memmap();
        else if (c == 'Z')
          poke(htoi(cmd + 2), segm, off);
        else if (c == '?')
          puts0("Commands:\r\n/Q - Quit\r\n/A - Ascii mode\r\n/H - Hex mode\r\n/M - Mix (hex & ascii) mode\r\n/S<hex_value> - set Segment\r\n/O<hex_value> - set Offset\r\n/K - print memory map\r\nEnter - next string\r\n/Z<hex_value> - poke hex_value to memory\r\n");
        else
          puts0("Invalid command\r\n");
      }
      puts0("\r\n");
    } else if (!cmd[0]) {
      off = (off + 16);
    } else
      ;
  }
}
```