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

```asm
<_gettemp>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %edx,0x4(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  test   %rsi,%rsi
  setne  %r13b
  test   %edx,%edx
  setne  0x3(%rsp)
  movzbl 0x3(%rsp),%eax
  test   %r13b,%r13b
  je     L315
  test   %al,%al
  je     L315
L100:
  mov    D86(%rip),%rax
  mov    (%rax),%rdx
  mov    D54(%rip),%rax
  mov    %rdx,(%rax)
  xor    %eax,%eax
L179:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L281
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L315:
  cmpb   $0x0,(%r12)
  mov    %r12,%rbx
  je     L24
  nopw   0x0(%rax,%rax,1)
L204:
  add    $0x1,%rbx
  cmpb   $0x0,(%rbx)
  jne    L204
L24:
  movslq %ecx,%rcx
  sub    %rcx,%rbx
  lea    -0x1(%rbx),%r15
  cmp    %r15,%r12
  ja     L100
  xor    %eax,%eax
  call   <getpid@plt>
  lea    -0x1(%r12),%rsi
  mov    %eax,%edx
  jmp    L116
L328:
  mov    %rdi,%r15
L116:
  movzbl (%r15),%eax
  cmp    $0x58,%al
  jne    L165
  test   %edx,%edx
  je     L165
  movslq %edx,%rax
  mov    %edx,%r9d
  lea    -0x1(%r15),%rdi
  imul   $0x66666667,%rax,%rax
  sar    $0x1f,%r9d
  sar    $0x22,%rax
  sub    %r9d,%eax
  lea    (%rax,%rax,4),%r9d
  add    %r9d,%r9d
  sub    %r9d,%edx
  add    $0x30,%edx
  mov    %dl,(%r15)
  mov    %eax,%edx
  cmp    %rsi,%rdi
  jne    L328
L14:
  mov    %r15,0x8(%rsp)
L413:
  lea    0x14(%rsp),%r13
L16:
  test   %rbp,%rbp
  je     L384
  mov    D50(%rip),%rax
  mov    $0x180,%edx
  mov    %r12,%rdi
  mov    (%rax),%esi
  mov    D1(%rip),%rax
  or     (%rax),%esi
  mov    D104(%rip),%rax
  or     (%rax),%esi
  call   <open@plt>
  mov    %eax,0x0(%rbp)
  test   %eax,%eax
  jns    L122
L392:
  mov    D51(%rip),%rax
  mov    D54(%rip),%rdx
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  jne    L169
L134:
  mov    0x8(%rsp),%r14
  movsbl (%r14),%edi
  test   %dil,%dil
  jne    L166
  jmp    L169
  nopl   (%rax)
L130:
  cmp    %r14,%rbx
  je     L169
  movsbl 0x1(%r14),%edi
  add    $0x1,%r14
  movb   $0x61,-0x1(%r14)
  test   %dil,%dil
  je     L169
L166:
  cmp    $0x5a,%dil
  je     L130
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L387
  movzbl (%r14),%eax
  cmp    $0x7a,%al
  je     L217
  cmp    %r14,%rbx
  je     L169
  add    $0x1,%eax
  jmp    L253
  nopl   0x0(%rax)
L165:
  cmp    %r15,%r12
  ja     L31
  mov    %r15,%r14
  jmp    L414
  cs nopw 0x0(%rax,%rax,1)
L30:
  add    $0x41,%edx
  mov    %dl,(%r14)
  cmp    %r14,%r12
  je     L14
L126:
  movzbl -0x1(%r14),%eax
  sub    $0x1,%r14
L414:
  mov    %r14,%r15
  cmp    $0x58,%al
  jne    L155
  xor    %eax,%eax
  call   <arc4random@plt>
  movzwl %ax,%edx
  mov    %rdx,%rax
  imul   $0x4ec4ec4f,%rdx,%rdx
  shr    $0x24,%rdx
  imul   $0x34,%edx,%edi
  sub    %edi,%eax
  mov    %eax,%edx
  cmp    $0x19,%eax
  jle    L30
  add    $0x47,%edx
  mov    %dl,(%r14)
  cmp    %r14,%r12
  jne    L126
  jmp    L14
  nopl   0x0(%rax,%rax,1)
L155:
  lea    0x1(%r14),%rax
  mov    %rax,0x8(%rsp)
  test   %r13b,%r13b
  jne    L232
  cmpb   $0x0,0x3(%rsp)
  je     L413
L232:
  cmp    %r14,%r12
  jb     L301
  jmp    L413
  nopl   0x0(%rax,%rax,1)
L177:
  sub    $0x1,%r15
  cmp    %r15,%r12
  je     L413
L301:
  cmpb   $0x2f,(%r15)
  jne    L177
  movb   $0x0,(%r15)
  lea    0x14(%rsp),%rsi
  mov    %r12,%rdi
  call   <stat@plt>
  movb   $0x2f,(%r15)
  test   %eax,%eax
  je     L176
L169:
  xor    %eax,%eax
  jmp    L179
  nopw   0x0(%rax,%rax,1)
L384:
  mov    0x4(%rsp),%eax
  test   %eax,%eax
  je     L147
  mov    $0x1c0,%esi
  mov    %r12,%rdi
  call   <mkdir@plt>
  test   %rax,%rax
  jne    L392
L122:
  mov    $0x1,%eax
  jmp    L179
  nopl   0x0(%rax,%rax,1)
L147:
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <lstat@plt>
  test   %rax,%rax
  je     L134
  mov    D54(%rip),%rdx
  mov    D6(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  sete   %al
  movzbl %al,%eax
  jmp    L179
  nopl   0x0(%rax,%rax,1)
L387:
  mov    $0x61,%eax
L253:
  mov    %al,(%r14)
  jmp    L16
L176:
  mov    0x14(%rsp),%edi
  call   <S_ISDIR@plt>
  test   %eax,%eax
  jne    L413
  mov    D67(%rip),%rdx
  mov    (%rdx),%rcx
  mov    D54(%rip),%rdx
  mov    %rcx,(%rdx)
  jmp    L179
L217:
  mov    $0x41,%eax
  jmp    L253
L281:
  call   <__stack_chk_fail@plt>
L31:
  add    $0x1,%r15
  jmp    L14
```

assistant: ```c
int _gettemp(char *path, int *doopen, int domkdir, int slen) {
  char *start, *trv, *suffp;
  struct stat sbuf;
  int rval;
  pid_t pid;
  if (doopen && domkdir) {
    errno = EINVAL;
    return (0);
  }
  for (trv = path; *trv; ++trv)
    ;
  trv -= slen;
  suffp = trv;
  --trv;
  if (trv < path) {
    errno = EINVAL;
    return (0);
  }
  pid = getpid();
  while (trv >= path && *trv == 'X' && pid != 0) {
    *trv-- = (pid % 10) + '0';
    pid /= 10;
  }
  while (trv >= path && *trv == 'X') {
    char c;
    pid = (arc4random() & 0xffff) % (26 + 26);
    if (pid < 26)
      c = pid + 'A';
    else
      c = (pid - 26) + 'a';
    *trv-- = c;
  }
  start = trv + 1;
  if (doopen || domkdir) {
    for (;; --trv) {
      if (trv <= path)
        break;
      if (*trv == '/') {
        *trv = '\0';
        rval = stat(path, &sbuf);
        *trv = '/';
        if (rval != 0)
          return (0);
        if (!S_ISDIR(sbuf.st_mode)) {
          errno = ENOTDIR;
          return (0);
        }
        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') {
        if (trv == suffp)
          return (0);
        *trv++ = 'a';
      } else {
        if (isdigit(*trv))
          *trv = 'a';
        else if (*trv == 'z')
          *trv = 'A';
        else {
          if (trv == suffp)
            return (0);
          ++*trv;
        }
        break;
      }
    }
  }
}
```