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

```asm
<pocl_mkstemp>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  call   <getpid@plt>
  mov    %eax,%edx
  movzbl 0x0(%rbp),%ecx
  test   %cl,%cl
  je     L142
  mov    %rbp,%r12
  mov    $0x0,%eax
  mov    $0x0,%esi
L18:
  add    $0x1,%eax
  cmp    $0x58,%cl
  cmovne %esi,%eax
  add    $0x1,%r12
  movzbl (%r12),%ecx
  test   %cl,%cl
  jne    L18
L215:
  lea    -0x1(%r12),%rbx
  cmpb   $0x58,-0x1(%r12)
  jne    L137
  mov    %rbx,%rcx
  movzbl D30(%rip),%esi
  mov    %sil,-0x1(%r12)
  cmp    $0x6,%eax
  jg     L98
L211:
  lea    -0x1(%rcx),%rbx
  cmpb   $0x58,-0x1(%rcx)
  jne    L30
L166:
  movslq %edx,%rax
  imul   $0x66666667,%rax,%rax
  sar    $0x22,%rax
  mov    %edx,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%eax
  lea    (%rax,%rax,4),%ecx
  add    %ecx,%ecx
  sub    %ecx,%edx
  add    $0x30,%edx
  mov    %dl,(%rbx)
  mov    %eax,%edx
  mov    %rbx,%r12
  sub    $0x1,%rbx
  cmpb   $0x58,(%rbx)
  je     L166
L137:
  movzbl D30(%rip),%eax
  cmp    $0x7a,%al
  je     L244
  add    $0x1,%eax
  mov    %al,D125(%rip)
L275:
  cmp    %rbx,%rbp
  jae    L225
L276:
  cmpb   $0x2f,(%rbx)
  je     L224
  sub    $0x1,%rbx
  cmp    %rbx,%rbp
  jne    L276
L225:
  mov    D125(%rip),%r13
L201:
  mov    0x0(%r13),%esi
  mov    D74(%rip),%rax
  or     (%rax),%esi
  mov    D119(%rip),%rax
  or     (%rax),%esi
  mov    $0x180,%edx
  mov    %rbp,%rdi
  call   <open@plt>
  test   %eax,%eax
  jns    L285
  mov    D5(%rip),%rdx
  mov    D116(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  jne    L54
  movzbl (%r12),%edi
  test   %dil,%dil
  je     L169
  mov    %r12,%rbx
L46:
  cmp    $0x7a,%dil
  jne    L181
  add    $0x1,%rbx
  movb   $0x61,-0x1(%rbx)
  movzbl (%rbx),%edi
  test   %dil,%dil
  jne    L46
  mov    $0x0,%eax
L285:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L151
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L142:
  mov    %rbp,%r12
  mov    $0x0,%eax
  jmp    L215
L98:
  cmpb   $0x58,-0x2(%r12)
  jne    L211
  lea    -0x2(%r12),%rcx
  movzbl D85(%rip),%eax
  mov    %al,-0x2(%r12)
  jmp    L211
L30:
  mov    %rcx,%r12
  jmp    L137
L244:
  movb   $0x61,D125(%rip)
  movzbl D85(%rip),%edx
  lea    0x1(%rdx),%eax
  cmp    $0x7a,%dl
  mov    $0x61,%edx
  cmove  %edx,%eax
  mov    %al,D17(%rip)
  jmp    L275
L224:
  movb   $0x0,(%rbx)
  lea    0x4(%rsp),%rsi
  mov    %rbp,%rdi
  call   <stat@plt>
  mov    %rax,%rdx
  mov    $0x0,%eax
  test   %rdx,%rdx
  jne    L285
  mov    0x4(%rsp),%edi
  call   <S_ISDIR@plt>
  test   %eax,%eax
  je     L133
  movb   $0x2f,(%rbx)
  jmp    L225
L133:
  mov    D17(%rip),%rdx
  mov    (%rdx),%rcx
  mov    D5(%rip),%rdx
  mov    %rcx,(%rdx)
  jmp    L285
L181:
  movzbl %dil,%edi
  call   <isdigit@plt>
  mov    %rax,%rdx
  mov    $0x61,%eax
  test   %rdx,%rdx
  jne    L31
  movzbl (%rbx),%eax
  add    $0x1,%eax
L31:
  mov    %al,(%rbx)
  jmp    L201
L54:
  mov    $0xffffffff,%eax
  jmp    L285
L169:
  mov    $0x0,%eax
  jmp    L285
L151:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int pocl_mkstemp(char *path) {
  int fd;
  char *start, *trv;
  struct stat sbuf;
  pid_t pid;
  static char xtra[2] = "aa";
  int xcnt = 0;
  pid = getpid();
  for (trv = path; *trv; ++trv)
    if (*trv == 'X')
      xcnt++;
    else
      xcnt = 0;
  if (*(trv - 1) == 'X')
    *--trv = xtra[0];
  if (xcnt > 6 && *(trv - 1) == 'X')
    *--trv = xtra[1];
  while (*--trv == 'X') {
    *trv = (pid % 10) + '0';
    pid /= 10;
  }
  if (xtra[0] != 'z')
    xtra[0]++;
  else {
    xtra[0] = 'a';
    if (xtra[1] != 'z')
      xtra[1]++;
    else
      xtra[1] = 'a';
  }
  for (start = trv + 1;; --trv) {
    if (trv <= path)
      break;
    if (*trv == '/') {
      *trv = '\0';
      if (stat(path, &sbuf))
        return (0);
      if (!S_ISDIR(sbuf.st_mode)) {
        errno = ENOTDIR;
        return (0);
      }
      *trv = '/';
      break;
    }
  }
  for (;;) {
    if ((fd = open(path, O_CREAT | O_EXCL | O_RDWR | 0, 0600)) >= 0)
      return (fd);
    if (errno != EEXIST)
      return -1;
    for (trv = start;;) {
      if (!*trv)
        return (0);
      if (*trv == 'z')
        *trv++ = 'a';
      else {
        if (isdigit((unsigned char)*trv))
          *trv = 'a';
        else
          ++*trv;
        break;
      }
    }
  }
}
```