user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<process_go_command_write>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %edi,%ebx
  mov    %esi,%ebp
  mov    %rdx,%r12
  lea    D70(%rip),%rdi
  call   <puts@plt>
  cmp    %ebp,%ebx
  jge    L13
  movslq %ebx,%rbx
  mov    (%r12,%rbx,8),%r12
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    %eax,%r13d
  mov    %eax,%ebx
  shr    $0x1f,%ebx
  add    %eax,%ebx
  sar    %ebx
  mov    %ebx,%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L5
  mov    %r13d,%edx
  shr    $0x1f,%edx
  lea    0x0(%r13,%rdx,1),%eax
  and    $0x1,%eax
  sub    %edx,%eax
  cmp    $0x1,%eax
  je     L132
L241:
  cmp    $0x1,%r13d
  jle    L63
  mov    %rbp,%r8
  mov    $0x0,%r9d
  mov    $0x2,%edi
  mov    $0x0,%r10d
L203:
  mov    %r8,%rcx
  movb   $0x0,(%r8)
  mov    %r9,%rdx
  jmp    L93
L13:
  lea    D12(%rip),%rdi
  call   <puts@plt>
  mov    $0x0,%eax
  jmp    L139
L5:
  lea    D10(%rip),%rdi
  call   <puts@plt>
  mov    $0x0,%eax
  jmp    L139
L132:
  lea    D6(%rip),%rdi
  call   <puts@plt>
  jmp    L241
L87:
  lea    -0x61(%rsi),%eax
  cmp    $0x5,%al
  ja     L180
  movsbl %sil,%esi
  sub    $0x57,%esi
L0:
  movzbl (%rcx),%eax
  shl    $0x4,%eax
  or     %esi,%eax
  mov    %al,(%rcx)
  add    $0x1,%rdx
  cmp    %rdx,%rdi
  je     L98
L93:
  movzbl (%r12,%rdx,1),%esi
  lea    -0x30(%rsi),%eax
  cmp    $0x9,%al
  ja     L87
  movsbl %sil,%esi
  sub    $0x30,%esi
  jmp    L0
L180:
  lea    -0x41(%rsi),%eax
  cmp    $0x5,%al
  ja     L96
  movsbl %sil,%esi
  sub    $0x37,%esi
  jmp    L0
L96:
  movsbl %sil,%esi
  lea    D45(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %rbp,%rdi
  call   <free@plt>
  mov    $0x0,%eax
L139:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L98:
  add    $0x1,%r10d
  add    $0x1,%r8
  add    $0x2,%rdi
  add    $0x2,%r9
  cmp    %r10d,%ebx
  jg     L203
  mov    $0xffffffff,%edx
  mov    $0x1,%esi
  mov    $0x0,%edi
  call   <crc32@plt>
  mov    %eax,%edx
  mov    $0x4,%esi
  mov    $0x0,%edi
  call   <crc32@plt>
  mov    %rax,%r12
  mov    $0x0,%r13d
L184:
  mov    %r12d,%edx
  movzbl 0x0(%rbp,%r13,1),%edi
  mov    $0x8,%esi
  call   <crc32@plt>
  mov    %rax,%r12
  add    $0x1,%r13
  cmp    %r13d,%ebx
  jg     L184
  mov    $0x4,%esi
  mov    $0x0,%edi
  call   <reverse_bits@plt>
  mov    %rax,%r13
  mov    $0x0,%r14d
L191:
  movzbl 0x0(%rbp,%r14,1),%edi
  mov    $0x8,%esi
  call   <reverse_bits@plt>
  mov    %al,0x0(%rbp,%r14,1)
  add    $0x1,%r14
  cmp    %r14d,%ebx
  jg     L191
  mov    $0x20,%esi
  mov    %r12,%rdi
  call   <reverse_bits@plt>
  mov    %rax,%r14
  lea    0xa(%rbx),%r15d
  mov    %r15d,%edi
  call   <malloc@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L116
  mov    %r15d,%edx
  mov    $0x0,%esi
  mov    %r12,%rdi
  call   <memset@plt>
  add    %r13d,%r13d
  mov    %r13b,(%r12)
  mov    $0x0,%eax
L69:
  movzbl 0x0(%rbp,%rax,1),%edx
  shl    $0x5,%edx
  or     %dl,(%r12,%rax,1)
  movzbl 0x0(%rbp,%rax,1),%edx
  shr    $0x3,%dl
  mov    %dl,0x1(%r12,%rax,1)
  add    $0x1,%rax
  cmp    %eax,%ebx
  jg     L69
L224:
  movslq %ebx,%r13
  mov    %r14d,%eax
  shl    $0x5,%eax
  or     %al,(%r12,%r13,1)
  mov    %r14,%rax
  shr    $0x3,%rax
  mov    %al,0x1(%r12,%r13,1)
  mov    %r14,%rax
  shr    $0xb,%rax
  mov    %al,0x2(%r12,%r13,1)
  mov    %r14,%rax
  shr    $0x13,%rax
  mov    %al,0x3(%r12,%r13,1)
  lea    0x4(%r12,%r13,1),%rax
  shr    $0x1b,%r14
  mov    %rax,0x8(%rsp)
  mov    %r14b,(%rax)
  mov    %r15d,%edx
  mov    %r12,%rsi
  lea    D125(%rip),%rdi
  call   <dump_jreg@plt>
  lea    0x49(,%rbx,8),%esi
  mov    %r12,%rdi
  call   <or1ksim_jtag_shift_dr@plt>
  movq   %xmm0,%rbx
  mov    %r15d,%edx
  mov    %r12,%rsi
  lea    D44(%rip),%rdi
  call   <dump_jreg@plt>
  movzbl 0x5(%r12,%r13,1),%edx
  movzbl 0x6(%r12,%r13,1),%eax
  shl    $0x7,%rax
  mov    %edx,%ecx
  shr    %cl
  movzbl %cl,%ecx
  or     %rcx,%rax
  movzbl 0x7(%r12,%r13,1),%ecx
  shl    $0xf,%rcx
  or     %rcx,%rax
  movzbl 0x8(%r12,%r13,1),%ecx
  shl    $0x17,%rcx
  or     %rcx,%rax
  movzbl 0x9(%r12,%r13,1),%ecx
  shl    $0x1f,%rcx
  mov    %rax,%r13
  or     %rcx,%r13
  mov    0x8(%rsp),%rax
  movzbl (%rax),%eax
  shr    $0x5,%al
  lea    0x0(,%rdx,8),%edi
  or     %eax,%edi
  and    $0xf,%edi
  mov    $0x4,%esi
  call   <reverse_bits@plt>
  mov    %rax,%r14
  mov    $0x20,%esi
  mov    %r13,%rdi
  call   <reverse_bits@plt>
  mov    %rax,%r15
  movzbl %r14b,%r13d
  mov    $0xffffffff,%edx
  mov    $0x4,%esi
  mov    %r13d,%edi
  call   <crc32@plt>
  mov    %rax,%r14
  mov    %r13d,%esi
  lea    D68(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  cmp    %r14,%r15
  jne    L234
L120:
  movq   %rbx,%xmm0
  lea    D54(%rip),%rdi
  mov    $0x1,%eax
  call   <printf@plt>
  mov    %rbp,%rdi
  call   <free@plt>
  mov    %r12,%rdi
  call   <free@plt>
  mov    $0x1,%eax
  jmp    L139
L116:
  lea    D99(%rip),%rdi
  call   <puts@plt>
  mov    %rbp,%rdi
  call   <free@plt>
  mov    $0x0,%eax
  jmp    L139
L234:
  lea    D85(%rip),%rdi
  call   <puts@plt>
  mov    %r15,%rsi
  lea    D35(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %r14,%rsi
  lea    D15(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L120
L63:
  mov    $0xffffffff,%edx
  mov    $0x1,%esi
  mov    $0x0,%edi
  call   <crc32@plt>
  mov    %eax,%edx
  mov    $0x4,%esi
  mov    $0x0,%edi
  call   <crc32@plt>
  mov    %rax,%r12
  mov    $0x4,%esi
  mov    $0x0,%edi
  call   <reverse_bits@plt>
  mov    %rax,%r13
  mov    $0x20,%esi
  mov    %r12,%rdi
  call   <reverse_bits@plt>
  mov    %rax,%r14
  lea    0xa(%rbx),%r15d
  mov    %r15d,%edi
  call   <malloc@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L116
  mov    %r15d,%edx
  mov    $0x0,%esi
  mov    %r12,%rdi
  call   <memset@plt>
  add    %r13d,%r13d
  mov    %r13b,(%r12)
  jmp    L224
```

tool_calls: name: read_data
arguments: tag: D70
data_type: string
name: read_data
arguments: tag: D12
data_type: string
name: read_data
arguments: tag: D10
data_type: string
name: read_data
arguments: tag: D6
data_type: string
name: read_data
arguments: tag: D45
data_type: string
name: read_data
arguments: tag: D125
data_type: string
name: read_data
arguments: tag: D44
data_type: string
name: read_data
arguments: tag: D68
data_type: string
name: read_data
arguments: tag: D54
data_type: string
name: read_data
arguments: tag: D99
data_type: string
name: read_data
arguments: tag: D85
data_type: string
name: read_data
arguments: tag: D35
data_type: string
name: read_data
arguments: tag: D15
data_type: string

tool: D70: Processing GO_COMMAND_WRITE.

tool: D12: GO_COMMAND_WRITE usage: GO_COMMAND_WRITE <data>.

tool: D10: ERROR: data malloc for GO_COMMAND_WRITE register failed.

tool: D6: Warning: GO_COMMAND_WRITE odd char ignored

tool: D45: ERROR: Non-hex digit in data: %c


tool: D125:   shifting in

tool: D44:   shifted out

tool: D68:   status:       0x%01x


tool: D54:   time taken:   %.12fs


tool: D99: ERROR: jreg malloc for GO_COMMAND_WRITE register failed.

tool: D85:   CRC mismatch

tool: D35:     CRC out:      0x%08lx


tool: D15:     CRC computed: 0x%08lx


assistant: ```c
int process_go_command_write(int next_jreg, int argc, char *argv[]) {
  printf("Processing GO_COMMAND_WRITE.\n");
  if (next_jreg >= argc) {
    printf("GO_COMMAND_WRITE usage: GO_COMMAND_WRITE <data>.\n");
    return 0;
  }
  unsigned long int cmd = 0;
  char *data_str = argv[next_jreg];
  int data_len = strlen(data_str);
  int data_bytes = data_len / 2;
  unsigned char *data = malloc(data_bytes);
  if (NULL == data) {
    printf("ERROR: data malloc for GO_COMMAND_WRITE register failed.\n");
    return 0;
  }
  if (1 == (data_len % 2)) {
    printf("Warning: GO_COMMAND_WRITE odd char ignored\n");
  }
  int i;
  for (i = 0; i < data_bytes; i++) {
    int ch_off_ms = i * 2;
    int ch_off_ls = i * 2 + 1;
    data[i] = 0;
    int j;
    for (j = ch_off_ms; j <= ch_off_ls; j++) {
      char c = data_str[j];
      int dig_val = (('0' <= c) && (c <= '9')) ? c - '0' : (('a' <= c) && (c <= 'f')) ? c - 'a' + 10 : (('A' <= c) && (c <= 'F')) ? c - 'A' + 10 : -1;
      if (dig_val < 0) {
        printf("ERROR: Non-hex digit in data: %c\n", c);
        free(data);
        return 0;
      }
      data[i] = (data[i] << 4) | dig_val;
    }
  }
  unsigned long int crc_in;
  crc_in = crc32(0, 1, 0xffffffff);
  crc_in = crc32(cmd, 4, crc_in);
  for (i = 0; i < data_bytes; i++) {
    crc_in = crc32(data[i], 8, crc_in);
  }
  cmd = reverse_bits(cmd, 4);
  for (i = 0; i < data_bytes; i++) {
    data[i] = reverse_bits(data[i], 8);
  }
  crc_in = reverse_bits(crc_in, 32);
  int num_bytes = 10 + data_bytes;
  unsigned char *jreg = malloc(num_bytes);
  if (NULL == jreg) {
    printf("ERROR: jreg malloc for GO_COMMAND_WRITE register failed.\n");
    free(data);
    return 0;
  }
  memset(jreg, 0, num_bytes);
  jreg[0] = 0x0;
  jreg[0] |= cmd << 1;
  for (i = 0; i < data_bytes; i++) {
    jreg[i] |= data[i] << 5;
    jreg[i + 1] = data[i] >> 3;
  }
  jreg[data_bytes] |= crc_in << 5;
  jreg[data_bytes + 1] = crc_in >> 3;
  jreg[data_bytes + 2] = crc_in >> 11;
  jreg[data_bytes + 3] = crc_in >> 19;
  jreg[data_bytes + 4] = crc_in >> 27;
  dump_jreg("  shifting in", jreg, num_bytes);
  double t = or1ksim_jtag_shift_dr(jreg, 32 + 4 + 32 + data_bytes * 8 + 4 + 1);
  dump_jreg("  shifted out", jreg, num_bytes);
  unsigned char status;
  unsigned long int crc_out;
  status = ((jreg[data_bytes + 4] >> 5) | (jreg[data_bytes + 5] << 3)) & 0xf;
  crc_out = ((unsigned long int)jreg[data_bytes + 5] >> 1) | ((unsigned long int)jreg[data_bytes + 6] << 7) | ((unsigned long int)jreg[data_bytes + 7] << 15) | ((unsigned long int)jreg[data_bytes + 8] << 23) | ((unsigned long int)jreg[data_bytes + 9] << 31);
  status = reverse_bits(status, 4);
  crc_out = reverse_bits(crc_out, 32);
  unsigned long int crc_computed = crc32(status, 4, 0xffffffff);
  printf("  status:       0x%01x\n", status);
  if (crc_out != crc_computed) {
    printf("  CRC mismatch\n");
    printf("    CRC out:      0x%08lx\n", crc_out);
    printf("    CRC computed: 0x%08lx\n", crc_computed);
  }
  printf("  time taken:   %.12fs\n", t);
  free(data);
  free(jreg);
  return 1;
}
```