user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<check_str_2>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  test   %rdi,%rdi
  je     L170
  mov    %rdi,%r13
  mov    %rsi,%r14
  mov    %rdx,%r12
  mov    %rcx,%r9
  mov    %r8d,%r15d
  test   %rdx,%rdx
  je     L85
  movb   $0x0,(%rdx)
L85:
  test   %r15d,%r15d
  je     L94
  mov    $0x10000,%edi
  mov    %r9,-0x50(%rbp)
  call   <alloca@plt>
  mov    $0x10000,%edx
  xor    %esi,%esi
  mov    %rax,%rdi
  mov    %rax,-0x48(%rbp)
  call   <memset@plt>
  mov    %r13,%rdi
  call   <strlen@plt>
  lea    0x4(,%rax,4),%edi
  call   <alloca@plt>
  mov    %r13,%rsi
  mov    %rax,%r15
  mov    %rax,%rdi
  call   <utf8_to_ucs4_str@plt>
  mov    (%r15),%ebx
  test   %ebx,%ebx
  je     L170
  mov    -0x50(%rbp),%r9
  mov    -0x48(%rbp),%r8
  mov    $0xffffffff,%r13d
  xor    %eax,%eax
  jmp    L154
  nopl   (%rax)
L44:
  cmpb   $0x0,0xff(%r14)
  jne    L139
  movslq %ebx,%rdx
  cmp    $0xffff,%ebx
  jle    L147
  nopl   (%rax)
L114:
  mov    $0x3f,%edx
  mov    $0x3f,%ebx
L147:
  cmp    %ebx,%r13d
  movb   $0x1,(%r8,%rdx,1)
  mov    $0xffffffff,%eax
  cmovl  %ebx,%r13d
L139:
  mov    0x4(%r15),%ebx
  add    $0x4,%r15
  test   %ebx,%ebx
  je     L236
L154:
  test   %ebx,%ebx
  js     L114
  cmp    $0x7f,%ebx
  jg     L44
  movslq %ebx,%rdx
  cmpb   $0x0,(%r14,%rdx,1)
  jne    L139
  cmp    $0x1f,%ebx
  jg     L147
  jmp    L114
  nopl   (%rax)
L94:
  mov    $0x100,%edi
  call   <alloca@plt>
  mov    $0x100,%edx
  xor    %esi,%esi
  mov    %rax,%rdi
  mov    %rax,%rbx
  call   <memset@plt>
  movzbl 0x0(%r13),%eax
  test   %al,%al
  je     L170
  nopl   0x0(%rax)
L0:
  cmpb   $0x0,(%r14,%rax,1)
  jne    L8
  add    $0x1,%r13
  movb   $0x1,(%rbx,%rax,1)
  mov    $0xffffffff,%r15d
  movzbl 0x0(%r13),%eax
  test   %al,%al
  jne    L0
L9:
  test   %r15d,%r15d
  jns    L10
  test   %r12,%r12
  je     L10
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L215:
  cmpb   $0x0,(%rbx,%rax,1)
  je     L277
  mov    %al,(%r12)
  add    $0x1,%r12
L277:
  add    $0x1,%rax
  cmp    $0x100,%rax
  jne    L215
  movb   $0x0,(%r12)
  mov    $0xffffffff,%eax
L45:
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  jne    L295
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  xchg   %ax,%ax
L8:
  movzbl 0x1(%r13),%eax
  add    $0x1,%r13
  test   %al,%al
  jne    L0
  jmp    L9
  nopl   0x0(%rax,%rax,1)
L236:
  test   %eax,%eax
  jns    L45
  test   %r12,%r12
  je     L45
  mov    %r9,-0x50(%rbp)
  mov    %r8,-0x48(%rbp)
  cmp    $0x1f,%r13d
  jle    L213
  lea    0x1(%r13),%r14d
  lea    0x0(,%r14,4),%edi
  call   <alloca@plt>
  mov    -0x48(%rbp),%r8
  mov    -0x50(%rbp),%r9
  mov    %rax,%r10
L145:
  movslq %r14d,%rcx
  xor    %edx,%edx
L208:
  cmpb   $0x0,(%r8,%rdx,1)
  je     L271
  movslq %ebx,%rax
  add    $0x1,%ebx
  mov    %edx,(%r10,%rax,4)
L271:
  add    $0x1,%rdx
  cmp    %rdx,%rcx
  jne    L208
  movslq %ebx,%rbx
  lea    (%r10,%rbx,4),%rax
L316:
  movl   $0x0,(%rax)
  mov    %r10,%rdx
  mov    %r9,%rsi
  mov    %r12,%rdi
  call   <ucs4_to_utf8_str@plt>
  mov    $0xffffffff,%eax
  jmp    L45
  nop
L170:
  xor    %eax,%eax
  jmp    L45
L213:
  lea    D28(%rip),%rcx
  mov    $0x34f,%esi
  lea    0x1(%r13),%r14d
  lea    D9(%rip),%rdx
  lea    D12(%rip),%rdi
  call   <swerr@plt>
  lea    0x0(,%r14,4),%edi
  call   <alloca@plt>
  cmp    $0xffffffff,%r13d
  mov    -0x48(%rbp),%r8
  mov    -0x50(%rbp),%r9
  mov    %rax,%r10
  jne    L145
  jmp    L316
L10:
  mov    %r15d,%eax
  jmp    L45
L295:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: tag: D28
data_type: string
name: unpack_data
arguments: tag: D9
data_type: string
name: unpack_data
arguments: tag: D12
data_type: string

tool: D28: maxinv >= ' '

tool: D9: assertion failed: %s

tool: D12: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/stden/ejudge/refs/heads/master/misctext.c

assistant: ```c
int check_str_2(const unsigned char *str, const unsigned char *map, unsigned char *invchars, size_t invsize, int utf8_flag) {
  unsigned char *invset;
  unsigned char *p = invchars;
  int retval = 0, i, slen, *wstr, maxinv = -1, invc, *ibuf, j;
  if (!str)
    return 0;
  if (p)
    *p = 0;
  if (!utf8_flag) {
    invset = (unsigned char *)alloca(256);
    memset(invset, 0, 256);
    for (; *str; str++)
      if (!map[*str]) {
        invset[*str] = 1;
        retval = -1;
      }
    if (retval >= 0 || !p)
      return retval;
    for (i = 0; i < 256; i++)
      if (invset[i])
        *p++ = i;
    *p = 0;
  } else {
    invset = (unsigned char *)alloca(65536);
    memset(invset, 0, 65536);
    slen = strlen(str);
    wstr = (int *)alloca((slen + 1) * sizeof(wstr[0]));
    utf8_to_ucs4_str(wstr, str);
    for (; *wstr; wstr++) {
      invc = -1;
      if (*wstr < 0) {
        invc = '?';
      } else if (*wstr >= 128) {
        if (!map[255]) {
          if (*wstr >= 65536)
            invc = '?';
          else
            invc = *wstr;
        }
      } else if (!map[*wstr]) {
        if (*wstr < 32)
          invc = '?';
        else
          invc = *wstr;
      }
      if (invc > 0) {
        invset[invc] = 1;
        retval = -1;
        if (invc > maxinv)
          maxinv = invc;
      }
    }
    if (retval >= 0 || !p)
      return retval;
    do {
      if (!(maxinv >= ' '))
        swerr("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/stden/ejudge/refs/heads/master/misctext.c", 847, "assertion failed: %s", "maxinv >= ' '");
    } while (0);
    ibuf = (int *)alloca((maxinv + 1) * sizeof(ibuf[0]));
    for (i = 0, j = 0; i <= maxinv; i++)
      if (invset[i])
        ibuf[j++] = i;
    ibuf[j++] = 0;
    ucs4_to_utf8_str(invchars, invsize, ibuf);
  }
  return retval;
}
```