user: What would the C source look like for the assembly code provided here?

```asm
<__gettemp>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%rbp
  mov    %rsi,%r12
  mov    %edx,%r13d
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  test   %rdi,%rdi
  setne  %dil
  movzbl %dil,%edi
  call   <_DIAGASSERT@plt>
  mov    $0x0,%eax
  call   <getpid@plt>
  mov    %eax,%edx
  movzbl 0x0(%rbp),%ecx
  test   %cl,%cl
  je     L181
  mov    %rbp,%r14
  mov    $0x0,%eax
  mov    $0x0,%esi
L82:
  add    $0x1,%eax
  cmp    $0x58,%cl
  cmovne %esi,%eax
  add    $0x1,%r14
  movzbl (%r14),%ecx
  test   %cl,%cl
  jne    L82
L334:
  lea    -0x1(%r14),%rbx
  cmpb   $0x58,-0x1(%r14)
  jne    L2
  mov    %rbx,%rcx
  movzbl D61(%rip),%esi
  mov    %sil,-0x1(%r14)
  cmp    $0x6,%eax
  jle    L3
  cmpb   $0x58,-0x2(%r14)
  jne    L3
  lea    -0x2(%r14),%rcx
  movzbl D143(%rip),%eax
  mov    %al,-0x2(%r14)
L3:
  lea    -0x1(%rcx),%rbx
  cmpb   $0x58,-0x1(%rcx)
  jne    L219
L228:
  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,%r14
  sub    $0x1,%rbx
  cmpb   $0x58,(%rbx)
  je     L228
L2:
  movzbl D61(%rip),%eax
  cmp    $0x7a,%al
  je     L245
  add    $0x1,%eax
  mov    %al,D8(%rip)
L87:
  cmp    %rbx,%rbp
  jae    L145
L141:
  cmpb   $0x2f,(%rbx)
  je     L304
  sub    $0x1,%rbx
  cmp    %rbx,%rbp
  jne    L141
L145:
  lea    0x4(%rsp),%r15
L317:
  test   %r12,%r12
  je     L339
  mov    D8(%rip),%rax
  mov    (%rax),%esi
  mov    D15(%rip),%rax
  or     (%rax),%esi
  mov    D149(%rip),%rax
  or     (%rax),%esi
  mov    $0x180,%edx
  mov    %rbp,%rdi
  call   <open@plt>
  mov    %eax,(%r12)
  test   %eax,%eax
  jns    L102
  mov    D119(%rip),%rdx
  mov    D161(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  jne    L54
L72:
  movzbl (%r14),%edi
  test   %dil,%dil
  je     L258
  mov    %r14,%rbx
L303:
  cmp    $0x7a,%dil
  jne    L360
  add    $0x1,%rbx
  movb   $0x61,-0x1(%rbx)
  movzbl (%rbx),%edi
  test   %dil,%dil
  jne    L303
  mov    $0x0,%eax
L38:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L192
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L181:
  mov    %rbp,%r14
  mov    $0x0,%eax
  jmp    L334
L219:
  mov    %rcx,%r14
  jmp    L2
L245:
  movb   $0x61,D8(%rip)
  movzbl D143(%rip),%edx
  lea    0x1(%rdx),%eax
  cmp    $0x7a,%dl
  mov    $0x61,%edx
  cmove  %edx,%eax
  mov    %al,D101(%rip)
  jmp    L87
L304:
  movb   $0x0,(%rbx)
  lea    0x4(%rsp),%rsi
  mov    %rbp,%rdi
  call   <stat@plt>
  movb   $0x2f,(%rbx)
  cmp    $0xffffffff,%eax
  je     L235
  mov    0x4(%rsp),%edi
  call   <S_ISDIR@plt>
  test   %eax,%eax
  jne    L145
  mov    D101(%rip),%rax
  mov    (%rax),%rdx
  mov    D119(%rip),%rax
  mov    %rdx,(%rax)
  test   %r12,%r12
  sete   %dl
  test   %r13d,%r13d
  sete   %al
  movzbl %al,%eax
  and    %edx,%eax
  jmp    L38
L235:
  test   %r12,%r12
  sete   %dl
  test   %r13d,%r13d
  sete   %al
  movzbl %al,%eax
  and    %edx,%eax
  jmp    L38
L339:
  test   %r13d,%r13d
  je     L214
  mov    $0x1c0,%esi
  mov    %rbp,%rdi
  call   <mkdir@plt>
  test   %rax,%rax
  jns    L268
  mov    D119(%rip),%rdx
  mov    D161(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  je     L72
  mov    $0x0,%eax
  jmp    L38
L214:
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <lstat@plt>
  test   %rax,%rax
  je     L72
  mov    D119(%rip),%rdx
  mov    D26(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  sete   %al
  movzbl %al,%eax
  jmp    L38
L360:
  movzbl %dil,%edi
  call   <isdigit@plt>
  mov    %rax,%rdx
  mov    $0x61,%eax
  test   %rdx,%rdx
  jne    L185
  movzbl (%rbx),%eax
  add    $0x1,%eax
L185:
  mov    %al,(%rbx)
  jmp    L317
L102:
  mov    $0x1,%eax
  jmp    L38
L54:
  mov    $0x0,%eax
  jmp    L38
L258:
  mov    $0x0,%eax
  jmp    L38
L268:
  mov    $0x1,%eax
  jmp    L38
L192:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int __gettemp(char *path, int *doopen, int domkdir) {
  char *start, *trv;
  struct stat sbuf;
  u_int pid;
  static char xtra[2] = "aa";
  int xcnt = 0;
  _DIAGASSERT(path != NULL);
  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 == '/') {
      int e;
      *trv = '\0';
      e = stat(path, &sbuf);
      *trv = '/';
      if (e == -1)
        return doopen == NULL && !domkdir;
      if (!S_ISDIR(sbuf.st_mode)) {
        errno = ENOTDIR;
        return doopen == NULL && !domkdir;
      }
      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((unsigned char)*trv))
          *trv = 'a';
        else
          ++*trv;
        break;
      }
    }
  }
}
```