user: 请将以下的汇编代码转换成C语言代码:

```asm
<chaz_OS_run_sh_via_cmd_exe>:
  endbr64
  push   %r13
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  movzbl (%rdi),%eax
  test   %al,%al
  je     L20
  lea    0x1(%rdi),%rdx
  xor    %edi,%edi
  jmp    L112
  nopw   0x0(%rax,%rax,1)
L27:
  cmp    $0x21,%al
  je     L29
  cmp    $0x22,%al
  jne    L113
L176:
  add    $0x2,%rdi
L160:
  movzbl (%rdx),%eax
  add    $0x1,%rdx
  test   %al,%al
  je     L128
L112:
  cmp    $0x25,%al
  je     L29
  jle    L27
  cmp    $0x5c,%al
  je     L176
L113:
  movzbl (%rdx),%eax
  add    $0x1,%rdx
  add    $0x1,%rdi
  test   %al,%al
  jne    L112
L128:
  add    $0x1,%rdi
  call   <malloc@plt>
  mov    %rax,%rbp
  movzbl (%rbx),%eax
  test   %al,%al
  je     L210
L174:
  lea    0x1(%rbx),%rdi
  mov    %rbp,%rdx
  jmp    L204
  nopl   0x0(%rax,%rax,1)
L9:
  cmp    $0x21,%al
  je     L104
  cmp    $0x22,%al
  jne    L135
L6:
  movb   $0x5c,(%rdx)
  add    $0x2,%rdx
  mov    %al,-0x1(%rdx)
L73:
  movzbl (%rdi),%eax
  add    $0x1,%rdi
  test   %al,%al
  je     L114
L204:
  cmp    $0x25,%al
  je     L104
  jle    L9
  cmp    $0x5c,%al
  je     L6
L135:
  add    $0x1,%rdi
  mov    %al,(%rdx)
  add    $0x1,%rdx
  movzbl -0x1(%rdi),%eax
  test   %al,%al
  jne    L204
L114:
  sub    $0x8,%rsp
  movb   $0x0,(%rdx)
  mov    %r12,%r8
  mov    %rbp,%rdx
  push   $0x0
  lea    D35(%rip),%r9
  lea    D6(%rip),%rcx
  lea    D5(%rip),%rsi
  lea    D28(%rip),%rdi
  call   <chaz_Util_join@plt>
  mov    %rax,%r12
  mov    %rax,%rdi
  call   <system@plt>
  mov    %r12,%rdi
  mov    %eax,%r13d
  call   <free@plt>
  mov    %rbp,%rdi
  call   <free@plt>
  add    $0x18,%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   (%rax)
L29:
  add    $0x3,%rdi
  jmp    L160
  nopl   0x0(%rax)
L104:
  movb   $0x22,(%rdx)
  add    $0x3,%rdx
  mov    %al,-0x2(%rdx)
  movb   $0x22,-0x1(%rdx)
  jmp    L73
  nopl   0x0(%rax,%rax,1)
L20:
  mov    $0x1,%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  movzbl (%rbx),%eax
  test   %al,%al
  jne    L174
L210:
  mov    %rbp,%rdx
  jmp    L114
```

tool_calls: name: read_data
arguments: data_tag: D35
type_infered: string
name: read_data
arguments: data_tag: D6
type_infered: string
name: read_data
arguments: data_tag: D5
type_infered: string
name: read_data
arguments: data_tag: D28
type_infered: string

tool: D35:  2>&1

tool: D6: " > 

tool: D5: sh -c "

tool: 

assistant: ```c
int chaz_OS_run_sh_via_cmd_exe(const char *command, const char *path) {
  size_t i;
  size_t size;
  char *escaped_command;
  char *wrapped_command;
  char *p;
  int retval;
  size = 0;
  for (i = 0; command[i] != '\0'; i++) {
    char c = command[i];
    switch (c) {
    case '"':
    case '\\':
      size += 2;
      break;
    case '%':
    case '!':
      size += 3;
      break;
    default:
      size += 1;
      break;
    }
  }
  escaped_command = (char *)malloc(size + 1);
  p = escaped_command;
  for (i = 0; command[i] != '\0'; i++) {
    char c = command[i];
    switch (c) {
    case '"':
    case '\\':
      *p++ = '\\';
      *p++ = c;
      break;
    case '%':
    case '!':
      *p++ = '"';
      *p++ = c;
      *p++ = '"';
      break;
    default:
      *p++ = c;
      break;
    }
  }
  *p++ = '\0';
  wrapped_command = chaz_Util_join("", "sh -c \"", escaped_command, "\" > ", path, " 2>&1", NULL);
  retval = system(wrapped_command);
  free(wrapped_command);
  free(escaped_command);
  return retval;
}
```