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     L289
  test   %al,%al
  je     L289
L35:
  mov    D46(%rip),%rax
  mov    (%rax),%rdx
  mov    D75(%rip),%rax
  mov    %rdx,(%rax)
  xor    %eax,%eax
L164:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L402
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L289:
  cmpb   $0x0,(%r12)
  mov    %r12,%rbx
  je     L366
  nopw   0x0(%rax,%rax,1)
L432:
  add    $0x1,%rbx
  cmpb   $0x0,(%rbx)
  jne    L432
L366:
  movslq %ecx,%rcx
  sub    %rcx,%rbx
  lea    -0x1(%rbx),%r15
  cmp    %r15,%r12
  ja     L35
  xor    %eax,%eax
  call   <getpid@plt>
  lea    -0x1(%r12),%rsi
  mov    %eax,%edx
  jmp    L331
L87:
  mov    %rdi,%r15
L331:
  movzbl (%r15),%eax
  cmp    $0x58,%al
  jne    L29
  test   %edx,%edx
  je     L29
  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    L87
L153:
  mov    %r15,0x8(%rsp)
L79:
  lea    0x14(%rsp),%r13
L311:
  test   %rbp,%rbp
  je     L22
  mov    D19(%rip),%rax
  mov    $0x180,%edx
  mov    %r12,%rdi
  mov    (%rax),%esi
  mov    D23(%rip),%rax
  or     (%rax),%esi
  mov    D91(%rip),%rax
  or     (%rax),%esi
  call   <open@plt>
  mov    %eax,0x0(%rbp)
  test   %eax,%eax
  jns    L411
L188:
  mov    D48(%rip),%rax
  mov    D75(%rip),%rdx
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  jne    L278
L386:
  mov    0x8(%rsp),%r14
  movsbl (%r14),%edi
  test   %dil,%dil
  jne    L126
  jmp    L278
  nopl   (%rax)
L112:
  cmp    %r14,%rbx
  je     L278
  movsbl 0x1(%r14),%edi
  add    $0x1,%r14
  movb   $0x61,-0x1(%r14)
  test   %dil,%dil
  je     L278
L126:
  cmp    $0x5a,%dil
  je     L112
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L403
  movzbl (%r14),%eax
  cmp    $0x7a,%al
  je     L121
  cmp    %r14,%rbx
  je     L278
  add    $0x1,%eax
  jmp    L31
  nopl   0x0(%rax)
L29:
  cmp    %r15,%r12
  ja     L82
  mov    %r15,%r14
  jmp    L376
  cs nopw 0x0(%rax,%rax,1)
L139:
  add    $0x41,%edx
  mov    %dl,(%r14)
  cmp    %r14,%r12
  je     L153
L279:
  movzbl -0x1(%r14),%eax
  sub    $0x1,%r14
L376:
  mov    %r14,%r15
  cmp    $0x58,%al
  jne    L88
  xor    %eax,%eax
  call   <random@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    L139
  add    $0x47,%edx
  mov    %dl,(%r14)
  cmp    %r14,%r12
  jne    L279
  jmp    L153
  nopl   0x0(%rax,%rax,1)
L88:
  lea    0x1(%r14),%rax
  mov    %rax,0x8(%rsp)
  test   %r13b,%r13b
  jne    L119
  cmpb   $0x0,0x3(%rsp)
  je     L79
L119:
  cmp    %r14,%r12
  jb     L215
  jmp    L79
  nopl   0x0(%rax,%rax,1)
L373:
  sub    $0x1,%r15
  cmp    %r15,%r12
  je     L79
L215:
  cmpb   $0x2f,(%r15)
  jne    L373
  movb   $0x0,(%r15)
  lea    0x14(%rsp),%rsi
  mov    %r12,%rdi
  call   <stat@plt>
  movb   $0x2f,(%r15)
  test   %eax,%eax
  je     L456
L278:
  xor    %eax,%eax
  jmp    L164
  nopw   0x0(%rax,%rax,1)
L22:
  mov    0x4(%rsp),%eax
  test   %eax,%eax
  je     L285
  mov    $0x1c0,%esi
  mov    %r12,%rdi
  call   <mkdir@plt>
  test   %rax,%rax
  jne    L188
L411:
  mov    $0x1,%eax
  jmp    L164
  nopl   0x0(%rax,%rax,1)
L285:
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <lstat@plt>
  test   %rax,%rax
  je     L386
  mov    D75(%rip),%rdx
  mov    D106(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  sete   %al
  movzbl %al,%eax
  jmp    L164
  nopl   0x0(%rax,%rax,1)
L403:
  mov    $0x61,%eax
L31:
  mov    %al,(%r14)
  jmp    L311
L456:
  mov    0x14(%rsp),%edi
  call   <S_ISDIR@plt>
  test   %eax,%eax
  jne    L79
  mov    D74(%rip),%rdx
  mov    (%rdx),%rcx
  mov    D75(%rip),%rdx
  mov    %rcx,(%rdx)
  jmp    L164
L121:
  mov    $0x41,%eax
  jmp    L31
L402:
  call   <__stack_chk_fail@plt>
L82:
  add    $0x1,%r15
  jmp    L153
```

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 = (random() & 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;
      }
    }
  }
}
```