user: Translate the below assembly code into C programming language:

```asm
<chaz_OS_run_sh_via_cmd_exe>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  movq   $0x0,-0x20(%rbp)
  movq   $0x0,-0x28(%rbp)
  jmp    L24
L150:
  mov    -0x38(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0x2d(%rbp)
  movsbl -0x2d(%rbp),%eax
  cmp    $0x5c,%eax
  je     L23
  cmp    $0x5c,%eax
  jg     L194
  cmp    $0x25,%eax
  je     L39
  cmp    $0x25,%eax
  jg     L194
  cmp    $0x21,%eax
  je     L39
  cmp    $0x22,%eax
  jne    L194
L23:
  addq   $0x2,-0x20(%rbp)
  jmp    L155
L39:
  addq   $0x3,-0x20(%rbp)
  jmp    L155
L194:
  addq   $0x1,-0x20(%rbp)
  nop
L155:
  addq   $0x1,-0x28(%rbp)
L24:
  mov    -0x38(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L150
  mov    -0x20(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  movq   $0x0,-0x28(%rbp)
  jmp    L11
L49:
  mov    -0x38(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0x2e(%rbp)
  movsbl -0x2e(%rbp),%eax
  cmp    $0x5c,%eax
  je     L73
  cmp    $0x5c,%eax
  jg     L97
  cmp    $0x25,%eax
  je     L143
  cmp    $0x25,%eax
  jg     L97
  cmp    $0x21,%eax
  je     L143
  cmp    $0x22,%eax
  jne    L97
L73:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x5c,(%rax)
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl -0x2e(%rbp),%edx
  mov    %dl,(%rax)
  jmp    L31
L143:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x22,(%rax)
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl -0x2e(%rbp),%edx
  mov    %dl,(%rax)
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x22,(%rax)
  jmp    L31
L97:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl -0x2e(%rbp),%edx
  mov    %dl,(%rax)
  nop
L31:
  addq   $0x1,-0x28(%rbp)
L11:
  mov    -0x38(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L49
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x0,(%rax)
  mov    -0x40(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  sub    $0x8,%rsp
  push   $0x0
  lea    D7(%rip),%r9
  mov    %rdx,%r8
  lea    D4(%rip),%rdx
  mov    %rdx,%rcx
  mov    %rax,%rdx
  lea    D25(%rip),%rax
  mov    %rax,%rsi
  lea    D9(%rip),%rax
  mov    %rax,%rdi
  call   <chaz_Util_join@plt>
  add    $0x10,%rsp
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <system@plt>
  mov    %eax,-0x2c(%rbp)
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x2c(%rbp),%eax
  leave
  ret
```

tool_calls: name: unpack_data
arguments: tag: D7
datatype: string
name: unpack_data
arguments: tag: D4
datatype: string
name: unpack_data
arguments: tag: D25
datatype: string
name: unpack_data
arguments: tag: D9
datatype: string

tool: D7:  2>&1

tool: D4: " > 

tool: D25: 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;
}
```