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

```asm
<os_server_start_2>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpl   $0x0,-0x3c(%rbp)
  je     L60
  mov    D64(%rip),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  je     L80
  mov    D64(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <fflush@plt>
  mov    D64(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  jmp    L105
L80:
  mov    $0x2,%edi
  call   <fsync@plt>
  mov    $0x2,%edi
  call   <close@plt>
L105:
  mov    D115(%rip),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  je     L78
  mov    D115(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <fflush@plt>
  mov    D115(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  jmp    L49
L78:
  mov    $0x1,%edi
  call   <fsync@plt>
  mov    $0x1,%edi
  call   <close@plt>
L49:
  mov    D52(%rip),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  je     L64
  mov    D52(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  jmp    L10
L64:
  mov    $0x0,%edi
  call   <close@plt>
L10:
  mov    $0x14,%esi
  mov    $0x3,%edi
  call   <os_close_files@plt>
L60:
  cmpq   $0x0,-0x38(%rbp)
  je     L69
  mov    -0x38(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L69
  mov    -0x38(%rbp),%rdx
  lea    -0x28(%rbp),%rcx
  lea    -0x24(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <os_uinfo@plt>
  test   %rax,%rax
  je     L111
  mov    $0xffffffff,%eax
  jmp    L109
L111:
  mov    $0x0,%eax
  call   <geteuid@plt>
  mov    %eax,-0x20(%rbp)
  mov    $0x0,%eax
  call   <getuid@plt>
  mov    %eax,-0x1c(%rbp)
  mov    $0x0,%eax
  call   <getegid@plt>
  mov    %eax,-0x18(%rbp)
  mov    $0x0,%eax
  call   <getgid@plt>
  mov    %eax,-0x14(%rbp)
  mov    $0x0,%edi
  call   <seteuid@plt>
  mov    -0x28(%rbp),%eax
  mov    %eax,%edi
  call   <setgid@plt>
  test   %rax,%rax
  je     L147
  mov    D35(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x20(%rbp),%eax
  mov    %eax,%edi
  call   <seteuid@plt>
  mov    D35(%rip),%rax
  mov    -0xc(%rbp),%edx
  mov    %edx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L109
L147:
  mov    -0x24(%rbp),%eax
  mov    %eax,%edi
  call   <setuid@plt>
  test   %rax,%rax
  je     L69
  mov    D35(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x20(%rbp),%eax
  mov    %eax,%edi
  call   <seteuid@plt>
  mov    -0x14(%rbp),%eax
  mov    %eax,%edi
  call   <setgid@plt>
  mov    -0x18(%rbp),%eax
  mov    %eax,%edi
  call   <setegid@plt>
  mov    D35(%rip),%rax
  mov    -0x10(%rbp),%edx
  mov    %edx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L109
L69:
  mov    $0x0,%eax
L109:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L71
  call   <__stack_chk_fail@plt>
L71:
  leave
  ret
```

assistant: ```c
int os_server_start_2(const char *user, int close_stdfiles) {
  int istat;
  gid_t gid, old_egid, old_gid;
  uid_t uid, old_euid, old_uid;
  if (close_stdfiles) {
    if (stderr) {
      fflush(stderr);
      fclose(stderr);
    } else {
      fsync(2);
      close(2);
    }
    if (stdout) {
      fflush(stdout);
      fclose(stdout);
    } else {
      fsync(1);
      close(1);
    }
    if (stdin)
      fclose(stdin);
    else
      close(0);
    os_close_files(3, 20);
  }
  if (user && *user) {
    if (os_uinfo(&uid, &gid, user))
      return (-1);
    old_euid = geteuid();
    old_uid = getuid();
    old_egid = getegid();
    old_gid = getgid();
    seteuid(0);
    if (setgid(gid)) {
      int save_errno = errno;
      seteuid(old_euid);
      errno = save_errno;
      return (-1);
    }
    if (setuid(uid)) {
      int save_errno = errno;
      seteuid(old_euid);
      setgid(old_gid);
      setegid(old_egid);
      errno = save_errno;
      return (-1);
    }
  }
  return (0);
}
```