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

```asm
<_gettemp>:
  endbr64
  push   %r15
  push   %r14
  mov    %rdi,%r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  test   %rsi,%rsi
  setne  %cl
  test   %edx,%edx
  setne  %sil
  test   %cl,%cl
  je     L243
  test   %sil,%sil
  je     L243
  mov    D22(%rip),%rax
  mov    (%rax),%rdx
  mov    D75(%rip),%rax
  mov    %rdx,(%rax)
  xor    %eax,%eax
L174:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L43
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L243:
  xor    %eax,%eax
  mov    %sil,0xf(%rsp)
  mov    %cl,0xe(%rsp)
  call   <getpid@plt>
  cmpb   $0x0,(%r14)
  movzbl 0xe(%rsp),%ecx
  movzbl 0xf(%rsp),%esi
  mov    %eax,%edx
  je     L253
  mov    %r14,%r13
  nopl   0x0(%rax)
L67:
  mov    %r13,%r15
  add    $0x1,%r13
  cmpb   $0x0,0x0(%r13)
  jne    L67
L349:
  cmpb   $0x58,-0x1(%r13)
  jne    L118
  nopl   (%rax)
L85:
  movslq %edx,%rax
  mov    %edx,%edi
  mov    %r15,%r13
  sub    $0x1,%r15
  imul   $0x66666667,%rax,%rax
  sar    $0x1f,%edi
  sar    $0x22,%rax
  sub    %edi,%eax
  lea    (%rax,%rax,4),%edi
  add    %edi,%edi
  sub    %edi,%edx
  add    $0x30,%edx
  mov    %dl,0x1(%r15)
  cmpb   $0x58,(%r15)
  mov    %eax,%edx
  je     L85
L118:
  test   %cl,%cl
  jne    L283
  test   %sil,%sil
  jne    L283
L321:
  lea    0x14(%rsp),%r15
  test   %rbx,%rbx
  je     L138
L8:
  mov    D47(%rip),%rax
  mov    $0x180,%edx
  mov    %r14,%rdi
  mov    (%rax),%esi
  mov    D20(%rip),%rax
  or     (%rax),%esi
  mov    D81(%rip),%rax
  or     (%rax),%esi
  call   <open@plt>
  mov    %eax,(%rbx)
  test   %eax,%eax
  jns    L37
L16:
  mov    D44(%rip),%rax
  mov    D75(%rip),%rdx
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  jne    L122
L217:
  movsbl (%r12),%edi
  test   %dil,%dil
  je     L122
  mov    %r12,%r13
  jmp    L177
  nopl   0x0(%rax)
L27:
  movsbl 0x1(%r13),%edi
  add    $0x1,%r13
  movb   $0x61,-0x1(%r13)
  test   %dil,%dil
  je     L122
L177:
  cmp    $0x7a,%dil
  je     L27
  call   <isdigit@plt>
  mov    %rax,%r8
  mov    $0x61,%eax
  test   %r8,%r8
  je     L276
  mov    %al,0x0(%r13)
L69:
  test   %rbx,%rbx
  jne    L8
L138:
  test   %ebp,%ebp
  je     L68
  mov    $0x1c0,%esi
  mov    %r14,%rdi
  call   <mkdir@plt>
  test   %rax,%rax
  jne    L16
L37:
  mov    $0x1,%eax
  jmp    L174
L122:
  xor    %eax,%eax
  jmp    L174
  nopw   0x0(%rax,%rax,1)
L283:
  cmp    %r15,%r14
  jb     L319
  jmp    L2
  nopw   0x0(%rax,%rax,1)
L88:
  sub    $0x1,%r15
  cmp    %r15,%r14
  je     L2
L319:
  cmpb   $0x2f,(%r15)
  jne    L88
  movb   $0x0,(%r15)
  lea    0x14(%rsp),%rsi
  mov    %r14,%rdi
  call   <stat@plt>
  test   %rax,%rax
  jne    L122
  mov    0x14(%rsp),%edi
  call   <S_ISDIR@plt>
  test   %eax,%eax
  je     L94
  movb   $0x2f,(%r15)
  mov    %r13,%r12
  jmp    L321
  nopw   0x0(%rax,%rax,1)
L276:
  movzbl 0x0(%r13),%eax
  add    $0x1,%eax
  mov    %al,0x0(%r13)
  jmp    L69
  nopl   0x0(%rax)
L68:
  mov    %r15,%rsi
  mov    %r14,%rdi
  call   <lstat@plt>
  test   %rax,%rax
  je     L217
  mov    D75(%rip),%rdx
  mov    D96(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  sete   %al
  movzbl %al,%eax
  jmp    L174
  nopl   0x0(%rax,%rax,1)
L2:
  mov    %r13,%r12
  jmp    L321
L253:
  lea    -0x1(%r14),%r15
  mov    %r14,%r13
  jmp    L349
L94:
  mov    D79(%rip),%rdx
  mov    (%rdx),%rcx
  mov    D75(%rip),%rdx
  mov    %rcx,(%rdx)
  jmp    L174
L43:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int _gettemp(char *path, int *doopen, int domkdir) {
  char *start, *trv;
  struct stat sbuf;
  pid_t pid;
  if (doopen && domkdir) {
    errno = EINVAL;
    return (0);
  }
  pid = getpid();
  for (trv = path; *trv; ++trv)
    ;
  while (*--trv == 'X') {
    *trv = (pid % 10) + '0';
    pid /= 10;
  }
  if (doopen || domkdir) {
    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 (doopen) {
      if ((*doopen = open(path, O_CREAT | O_EXCL | O_RDWR, 0600)) >= 0)
        return (1);
      if (errno != EEXIST)
        return (0);
    } else if (domkdir) {
      if (mkdir(path, 0700) == 0)
        return (1);
      if (errno != EEXIST)
        return (0);
    } else if (lstat(path, &sbuf))
      return (errno == ENOENT ? 1 : 0);
    for (trv = start;;) {
      if (!*trv)
        return (0);
      if (*trv == 'z')
        *trv++ = 'a';
      else {
        if (isdigit(*trv))
          *trv = 'a';
        else
          ++*trv;
        break;
      }
    }
  }
}
```