user: What is the c source code of the assembly code below?

```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     L89
  lea    0x1(%rdi),%rdx
  xor    %edi,%edi
  jmp    L29
  nopw   0x0(%rax,%rax,1)
L12:
  cmp    $0x21,%al
  je     L115
  cmp    $0x22,%al
  jne    L187
L177:
  add    $0x2,%rdi
L175:
  movzbl (%rdx),%eax
  add    $0x1,%rdx
  test   %al,%al
  je     L164
L29:
  cmp    $0x25,%al
  je     L115
  jle    L12
  cmp    $0x5c,%al
  je     L177
L187:
  movzbl (%rdx),%eax
  add    $0x1,%rdx
  add    $0x1,%rdi
  test   %al,%al
  jne    L29
L164:
  add    $0x1,%rdi
  call   <malloc@plt>
  mov    %rax,%rbp
  movzbl (%rbx),%eax
  test   %al,%al
  je     L72
L138:
  lea    0x1(%rbx),%rdi
  mov    %rbp,%rdx
  jmp    L31
  nopl   0x0(%rax,%rax,1)
L203:
  cmp    $0x21,%al
  je     L133
  cmp    $0x22,%al
  jne    L69
L50:
  movb   $0x5c,(%rdx)
  add    $0x2,%rdx
  mov    %al,-0x1(%rdx)
L150:
  movzbl (%rdi),%eax
  add    $0x1,%rdi
  test   %al,%al
  je     L162
L31:
  cmp    $0x25,%al
  je     L133
  jle    L203
  cmp    $0x5c,%al
  je     L50
L69:
  add    $0x1,%rdi
  mov    %al,(%rdx)
  add    $0x1,%rdx
  movzbl -0x1(%rdi),%eax
  test   %al,%al
  jne    L31
L162:
  sub    $0x8,%rsp
  movb   $0x0,(%rdx)
  mov    %r12,%r8
  mov    %rbp,%rdx
  push   $0x0
  lea    D3(%rip),%r9
  lea    D9(%rip),%rcx
  lea    D6(%rip),%rsi
  lea    D36(%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)
L115:
  add    $0x3,%rdi
  jmp    L175
  nopl   0x0(%rax)
L133:
  movb   $0x22,(%rdx)
  add    $0x3,%rdx
  mov    %al,-0x2(%rdx)
  movb   $0x22,-0x1(%rdx)
  jmp    L150
  nopl   0x0(%rax,%rax,1)
L89:
  mov    $0x1,%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  movzbl (%rbx),%eax
  test   %al,%al
  jne    L138
L72:
  mov    %rbp,%rdx
  jmp    L162
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D3
type_infered: string
name: extract_symbolic_data
arguments: data_label: D9
type_infered: string
name: extract_symbolic_data
arguments: data_label: D6
type_infered: string
name: extract_symbolic_data
arguments: data_label: D36
type_infered: string

tool: D3:  2>&1

tool: D9: " > 

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