user: Demonstrate the C code that generates the assembly output below:

```asm
<__gettemp>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rdi,%r13
  push   %r12
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  test   %rdi,%rdi
  setne  %dil
  movzbl %dil,%edi
  call   <_DIAGASSERT@plt>
  xor    %eax,%eax
  call   <getpid@plt>
  movzbl 0x0(%r13),%edi
  mov    %eax,%edx
  test   %dil,%dil
  je     L244
  mov    %r13,%rcx
  xor    %eax,%eax
  xor    %r8d,%r8d
  jmp    L337
  nopl   0x0(%rax,%rax,1)
L9:
  mov    %r15,%rcx
  mov    %esi,%edi
L337:
  movzbl 0x1(%rcx),%esi
  add    $0x1,%eax
  cmp    $0x58,%dil
  lea    0x1(%rcx),%r15
  cmovne %r8d,%eax
  test   %sil,%sil
  jne    L9
  movzbl D77(%rip),%esi
  cmp    $0x58,%dil
  je     L0
L51:
  mov    %rcx,%r12
  nopl   0x0(%rax)
L65:
  cmp    $0x7a,%sil
  je     L347
  add    $0x1,%esi
  mov    %sil,D1(%rip)
L143:
  cmp    %r12,%r13
  jb     L157
  jmp    L167
  nopl   0x0(%rax,%rax,1)
L201:
  sub    $0x1,%r12
  cmp    %r12,%r13
  je     L167
L157:
  cmpb   $0x2f,(%r12)
  jne    L201
  movb   $0x0,(%r12)
  lea    0x4(%rsp),%rsi
  mov    %r13,%rdi
  call   <stat@plt>
  movb   $0x2f,(%r12)
  cmp    $0xffffffff,%eax
  je     L102
  mov    0x4(%rsp),%edi
  call   <S_ISDIR@plt>
  test   %eax,%eax
  je     L257
L167:
  lea    0x4(%rsp),%r14
  test   %rbx,%rbx
  je     L62
L330:
  mov    D1(%rip),%rax
  mov    $0x180,%edx
  mov    %r13,%rdi
  mov    (%rax),%esi
  mov    D22(%rip),%rax
  or     (%rax),%esi
  mov    D3(%rip),%rax
  or     (%rax),%esi
  call   <open@plt>
  mov    %eax,(%rbx)
  test   %eax,%eax
  jns    L172
L357:
  mov    D58(%rip),%rax
  mov    D117(%rip),%rdx
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  jne    L341
L220:
  movzbl (%r15),%edi
  test   %dil,%dil
  je     L341
  mov    %r15,%r12
  jmp    L97
  nopl   0x0(%rax)
L176:
  movzbl 0x1(%r12),%edi
  add    $0x1,%r12
  movb   $0x61,-0x1(%r12)
  test   %dil,%dil
  je     L341
L97:
  cmp    $0x7a,%dil
  je     L176
  call   <isdigit@plt>
  mov    %rax,%r8
  mov    $0x61,%eax
  test   %r8,%r8
  je     L24
  mov    %al,(%r12)
L119:
  test   %rbx,%rbx
  jne    L330
L62:
  test   %ebp,%ebp
  je     L16
  mov    $0x1c0,%esi
  mov    %r13,%rdi
  call   <mkdir@plt>
  test   %rax,%rax
  js     L357
L172:
  mov    $0x1,%eax
  jmp    L194
  nopw   0x0(%rax,%rax,1)
L341:
  xor    %eax,%eax
L194:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L229
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L24:
  movzbl (%r12),%eax
  add    $0x1,%eax
  mov    %al,(%r12)
  jmp    L119
  cs nopw 0x0(%rax,%rax,1)
L16:
  mov    %r14,%rsi
  mov    %r13,%rdi
  call   <lstat@plt>
  test   %rax,%rax
  je     L220
  mov    D117(%rip),%rdx
  mov    D17(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  sete   %al
  movzbl %al,%eax
  jmp    L194
L347:
  movzbl D53(%rip),%edx
  movb   $0x61,D1(%rip)
  lea    0x1(%rdx),%eax
  cmp    $0x7a,%dl
  mov    $0x61,%edx
  cmove  %edx,%eax
  mov    %al,D121(%rip)
  jmp    L143
  nopw   0x0(%rax,%rax,1)
L0:
  mov    %sil,-0x1(%r15)
  cmp    $0x6,%eax
  jle    L61
  cmpb   $0x58,-0x2(%r15)
  jne    L266
  movzbl D121(%rip),%eax
  sub    $0x1,%rcx
  lea    -0x3(%r15),%r12
  mov    %al,-0x2(%r15)
  movzbl -0x3(%r15),%eax
L361:
  cmp    $0x58,%al
  jne    L233
  nopl   0x0(%rax,%rax,1)
L243:
  movslq %edx,%rax
  mov    %edx,%ecx
  mov    %r12,%r15
  sub    $0x1,%r12
  imul   $0x66666667,%rax,%rax
  sar    $0x1f,%ecx
  sar    $0x22,%rax
  sub    %ecx,%eax
  lea    (%rax,%rax,4),%ecx
  add    %ecx,%ecx
  sub    %ecx,%edx
  add    $0x30,%edx
  mov    %dl,0x1(%r12)
  cmpb   $0x58,(%r12)
  mov    %eax,%edx
  je     L243
  jmp    L65
L257:
  mov    D121(%rip),%rax
  mov    (%rax),%rdx
  mov    D117(%rip),%rax
  mov    %rdx,(%rax)
L102:
  test   %rbx,%rbx
  sete   %dl
  xor    %eax,%eax
  test   %ebp,%ebp
  sete   %al
  and    %edx,%eax
  jmp    L194
L244:
  cmpb   $0x58,-0x1(%r13)
  movzbl D1(%rip),%esi
  lea    -0x1(%r13),%rcx
  mov    %r13,%r15
  jne    L51
  mov    %sil,-0x1(%r13)
L61:
  movzbl -0x2(%r15),%eax
  lea    -0x1(%rcx),%r12
  jmp    L361
L233:
  mov    %rcx,%r15
  jmp    L65
L266:
  mov    %rcx,%r15
  sub    $0x1,%rcx
  jmp    L51
L229:
  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;
      }
    }
  }
}
```