user: 请从给定的汇编指令推导出C源代码:

```asm
<gdb_cmd_write_mem_hex>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %rdi,-0x58(%rbp)
  mov    %esi,-0x5c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  mov    %rsp,%rax
  mov    %rax,%rbx
  lea    D2(%rip),%rax
  mov    %rax,-0x40(%rbp)
  movl   $0x10,-0x48(%rbp)
  mov    -0x48(%rbp),%eax
  cltq
  sub    $0x1,%rax
  mov    %rax,-0x38(%rbp)
  mov    -0x48(%rbp),%eax
  cltq
  mov    %rax,%r10
  mov    $0x0,%r11d
  mov    -0x48(%rbp),%eax
  cltq
  mov    %rax,%r8
  mov    $0x0,%r9d
  mov    -0x48(%rbp),%eax
  cltq
  mov    $0x10,%edx
  sub    $0x1,%rdx
  add    %rdx,%rax
  mov    $0x10,%ecx
  mov    $0x0,%edx
  div    %rcx
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L8:
  cmp    %rdx,%rsp
  je     L33
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L8
L33:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L6
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L6:
  mov    %rsp,%rax
  add    $0x0,%rax
  mov    %rax,-0x30(%rbp)
  cmpl   $0x0,-0x5c(%rbp)
  jle    L13
  mov    -0x48(%rbp),%edx
  mov    -0x58(%rbp),%rsi
  mov    -0x30(%rbp),%rax
  mov    %edx,%ecx
  mov    $0x2c,%edx
  mov    %rax,%rdi
  call   <util_cpy_substr@plt>
  mov    %eax,-0x44(%rbp)
  mov    -0x44(%rbp),%eax
  cltq
  add    $0x1,%rax
  add    %rax,-0x58(%rbp)
  mov    -0x44(%rbp),%eax
  add    $0x1,%eax
  sub    %eax,-0x5c(%rbp)
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <util_hex_to_word@plt>
  mov    %rax,-0x28(%rbp)
  mov    -0x48(%rbp),%edx
  mov    -0x58(%rbp),%rsi
  mov    -0x30(%rbp),%rax
  mov    %edx,%ecx
  mov    $0x3a,%edx
  mov    %rax,%rdi
  call   <util_cpy_substr@plt>
  mov    %eax,-0x44(%rbp)
  mov    -0x44(%rbp),%eax
  cltq
  add    $0x1,%rax
  add    %rax,-0x58(%rbp)
  mov    -0x44(%rbp),%eax
  add    $0x1,%eax
  sub    %eax,-0x5c(%rbp)
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <util_hex_to_word@plt>
  mov    %rax,-0x20(%rbp)
  mov    -0x28(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %eax,%esi
  mov    -0x58(%rbp),%rax
  mov    $0x400,%ecx
  mov    %rax,%rdi
  call   <gdb_read_hex_data@plt>
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <util_str_len@plt>
  mov    %eax,%edx
  mov    -0x40(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <gdb_send_packet@plt>
L13:
  mov    %rbx,%rsp
  nop
  mov    -0x18(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L18
  call   <__stack_chk_fail@plt>
L18:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: parse_data
arguments: tag: D2
data_type: string

tool: D2: OK

assistant: ```c
void gdb_cmd_write_mem_hex(char *gdb_in_packet, int packet_len) {
  uint32_t addr;
  uint32_t bytes;
  int len;
  char *resp_str = "OK";
  const int scratch_len = 16;
  char scratchpad[scratch_len];
  if (packet_len > 0) {
    len = util_cpy_substr(scratchpad, (char *)gdb_in_packet, ',', scratch_len);
    gdb_in_packet += len + 1;
    packet_len -= (len + 1);
    addr = util_hex_to_word(scratchpad);
    len = util_cpy_substr(scratchpad, (char *)gdb_in_packet, ':', scratch_len);
    gdb_in_packet += len + 1;
    packet_len -= (len + 1);
    bytes = util_hex_to_word(scratchpad);
    gdb_read_hex_data((uint8_t *)gdb_in_packet, (int)bytes, (uint8_t *)addr, 1024);
    gdb_send_packet(resp_str, util_str_len(resp_str));
  }
}
```