user: Translate the below assembly code into C programming language:

```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     L348
  test   %al,%al
  je     L348
L102:
  mov    D54(%rip),%rax
  mov    (%rax),%rdx
  mov    D10(%rip),%rax
  mov    %rdx,(%rax)
  xor    %eax,%eax
L101:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L322
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L348:
  cmpb   $0x0,(%r12)
  mov    %r12,%rbx
  je     L290
  nopw   0x0(%rax,%rax,1)
L55:
  add    $0x1,%rbx
  cmpb   $0x0,(%rbx)
  jne    L55
L290:
  movslq %ecx,%rcx
  sub    %rcx,%rbx
  lea    -0x1(%rbx),%r15
  cmp    %r15,%r12
  ja     L102
  xor    %eax,%eax
  call   <getpid@plt>
  lea    -0x1(%r12),%rsi
  mov    %eax,%edx
  jmp    L145
L295:
  mov    %rdi,%r15
L145:
  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    L295
L104:
  mov    %r15,0x8(%rsp)
L383:
  lea    0x14(%rsp),%r13
L276:
  test   %rbp,%rbp
  je     L393
  mov    D105(%rip),%rax
  mov    $0x180,%edx
  mov    %r12,%rdi
  mov    (%rax),%esi
  mov    D80(%rip),%rax
  or     (%rax),%esi
  mov    D71(%rip),%rax
  or     (%rax),%esi
  call   <open@plt>
  mov    %eax,0x0(%rbp)
  test   %eax,%eax
  jns    L307
L107:
  mov    D29(%rip),%rax
  mov    D10(%rip),%rdx
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  jne    L127
L156:
  mov    0x8(%rsp),%r14
  movsbl (%r14),%edi
  test   %dil,%dil
  jne    L397
  jmp    L127
  nopl   (%rax)
L214:
  cmp    %r14,%rbx
  je     L127
  movsbl 0x1(%r14),%edi
  add    $0x1,%r14
  movb   $0x61,-0x1(%r14)
  test   %dil,%dil
  je     L127
L397:
  cmp    $0x5a,%dil
  je     L214
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L411
  movzbl (%r14),%eax
  cmp    $0x7a,%al
  je     L134
  cmp    %r14,%rbx
  je     L127
  add    $0x1,%eax
  jmp    L69
  nopl   0x0(%rax)
L29:
  cmp    %r15,%r12
  ja     L172
  mov    %r15,%r14
  jmp    L422
  cs nopw 0x0(%rax,%rax,1)
L142:
  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
  lea    0x41(%rax),%edi
  lea    0x47(%rax),%eax
  cmp    $0x19,%edx
  cmovle %edi,%eax
  mov    %al,(%r14)
  cmp    %r14,%r12
  je     L104
  movzbl -0x1(%r14),%eax
  sub    $0x1,%r14
L422:
  mov    %r14,%r15
  cmp    $0x58,%al
  je     L142
  lea    0x1(%r14),%rcx
  mov    %rcx,0x8(%rsp)
  test   %r13b,%r13b
  jne    L439
  cmpb   $0x0,0x3(%rsp)
  je     L383
L439:
  cmp    %r14,%r12
  jb     L141
  jmp    L383
  nopw   0x0(%rax,%rax,1)
L388:
  sub    $0x1,%r15
  cmp    %r15,%r12
  je     L383
  movzbl (%r15),%eax
L141:
  cmp    $0x2f,%al
  jne    L388
  movb   $0x0,(%r15)
  lea    0x14(%rsp),%rsi
  mov    %r12,%rdi
  call   <stat@plt>
  movb   $0x2f,(%r15)
  test   %eax,%eax
  je     L309
  nopw   0x0(%rax,%rax,1)
L127:
  xor    %eax,%eax
  jmp    L101
  nop
L393:
  mov    0x4(%rsp),%eax
  test   %eax,%eax
  je     L44
  mov    $0x1c0,%esi
  mov    %r12,%rdi
  call   <mkdir@plt>
  test   %rax,%rax
  jne    L107
L307:
  mov    $0x1,%eax
  jmp    L101
  nopl   0x0(%rax,%rax,1)
L44:
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <lstat@plt>
  test   %rax,%rax
  je     L156
  mov    D10(%rip),%rdx
  mov    D90(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  sete   %al
  movzbl %al,%eax
  jmp    L101
  nopl   0x0(%rax,%rax,1)
L411:
  mov    $0x61,%eax
L69:
  mov    %al,(%r14)
  jmp    L276
L309:
  mov    0x14(%rsp),%edi
  call   <S_ISDIR@plt>
  test   %eax,%eax
  jne    L383
  mov    D37(%rip),%rdx
  mov    (%rdx),%rcx
  mov    D10(%rip),%rdx
  mov    %rcx,(%rdx)
  jmp    L101
L134:
  mov    $0x41,%eax
  jmp    L69
L322:
  call   <__stack_chk_fail@plt>
L172:
  add    $0x1,%r15
  jmp    L104
```

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;
      }
    }
  }
}
```