// File: /workspace/github_c_makefile_star2_O0/arachsys[P]init/daemon.c
// Function: logger_start
static void logger_start(void) {
  int logpipe[2];

  /* Redirect stdout and stderr to /dev/null if logging isn't configured. */
  if (!logger.tag) {
    if (dup2(STDIN_FILENO, STDOUT_FILENO) < 0)
      err(EXIT_FAILURE, "dup2");
    if (dup2(STDIN_FILENO, STDERR_FILENO) < 0)
      err(EXIT_FAILURE, "dup2");
    return;
  }

  /* Redirect stdout and stderr if a log file has been specified. */
  if (*logger.tag == '/') {
    if (dup2(logger.fd, STDOUT_FILENO) < 0)
      err(EXIT_FAILURE, "dup2");
    if (dup2(logger.fd, STDERR_FILENO) < 0)
      err(EXIT_FAILURE, "dup2");
    if (logger.fd != STDOUT_FILENO && logger.fd != STDERR_FILENO)
      close(logger.fd);
    return;
  }

  if (pipe(logpipe) < 0)
    err(EXIT_FAILURE, "pipe");
  switch (fork()) {
    case -1:
      err(EXIT_FAILURE, "fork");
    case 0:
      /* Don't unintentionally keep the pwd busy in the logger process. */
      if (chdir("/") < 0)
        err(EXIT_FAILURE, "chdir");
      /* Redirect stdout and stderr to /dev/null for the logger process. */
      if (dup2(STDIN_FILENO, STDOUT_FILENO) < 0)
        err(EXIT_FAILURE, "dup2");
      if (dup2(STDIN_FILENO, STDERR_FILENO) < 0)
        err(EXIT_FAILURE, "dup2");
      /* Run logger(1) with stdin coming from the read end of the pipe. */
      if (dup2(logpipe[0], STDIN_FILENO) < 0)
        err(EXIT_FAILURE, "dup2");
      close(logpipe[0]);
      close(logpipe[1]);
      execlp("logger", "logger",
          "-p", logger.priority ? logger.priority : "daemon.notice",
          "-t", logger.tag, NULL);
      err(EXIT_FAILURE, "exec");
  }

  /* Redirect our stdout and stderr to the write end of the pipe. */
  if (dup2(logpipe[1], STDOUT_FILENO) < 0)
    err(EXIT_FAILURE, "dup2");
  if (dup2(logpipe[1], STDERR_FILENO) < 0)
    err(EXIT_FAILURE, "dup2");
  close(logpipe[0]);
  close(logpipe[1]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
cmpq $0x0, 0x2fa8(%rip)      # 0x6238
jne 0x32df
xorl %edi, %edi
movl $0x1, %esi
callq 0x20f0
cmpl $0x0, %eax
jge 0x32b6
movl $0x1, %edi
leaq 0xdb8(%rip), %rsi       # 0x4067
movb $0x0, %al
callq 0x2230
xorl %edi, %edi
movl $0x2, %esi
callq 0x20f0
cmpl $0x0, %eax
jge 0x32da
movl $0x1, %edi
leaq 0xd94(%rip), %rsi       # 0x4067
movb $0x0, %al
callq 0x2230
jmp 0x3514
movq 0x2f52(%rip), %rax      # 0x6238
movsbl (%rax), %eax
cmpl $0x2f, %eax
jne 0x3360
movl 0x2f4c(%rip), %edi      # 0x6240
movl $0x1, %esi
callq 0x20f0
cmpl $0x0, %eax
jge 0x3316
movl $0x1, %edi
leaq 0xd58(%rip), %rsi       # 0x4067
movb $0x0, %al
callq 0x2230
movl 0x2f24(%rip), %edi      # 0x6240
movl $0x2, %esi
callq 0x20f0
cmpl $0x0, %eax
jge 0x333e
movl $0x1, %edi
leaq 0xd30(%rip), %rsi       # 0x4067
movb $0x0, %al
callq 0x2230
cmpl $0x1, 0x2efb(%rip)      # 0x6240
je 0x335b
cmpl $0x2, 0x2ef2(%rip)      # 0x6240
je 0x335b
movl 0x2eea(%rip), %edi      # 0x6240
callq 0x2160
jmp 0x3514
leaq -0x8(%rbp), %rdi
callq 0x2180
cmpl $0x0, %eax
jge 0x3381
movl $0x1, %edi
leaq 0xd6c(%rip), %rsi       # 0x40e6
movb $0x0, %al
callq 0x2230
callq 0x23c0
movl %eax, %ecx
movl %ecx, -0xc(%rbp)
subl $-0x1, %eax
je 0x339e
jmp 0x3392
movl -0xc(%rbp), %eax
testl %eax, %eax
je 0x33b1
jmp 0x34ba
movl $0x1, %edi
leaq 0xd10(%rip), %rsi       # 0x40ba
movb $0x0, %al
callq 0x2230
leaq 0x131a(%rip), %rdi      # 0x46d2
callq 0x20d0
cmpl $0x0, %eax
jge 0x33d5
movl $0x1, %edi
leaq 0xd12(%rip), %rsi       # 0x40e0
movb $0x0, %al
callq 0x2230
xorl %edi, %edi
movl $0x1, %esi
callq 0x20f0
cmpl $0x0, %eax
jge 0x33f9
movl $0x1, %edi
leaq 0xc75(%rip), %rsi       # 0x4067
movb $0x0, %al
callq 0x2230
xorl %edi, %edi
movl $0x2, %esi
callq 0x20f0
cmpl $0x0, %eax
jge 0x341d
movl $0x1, %edi
leaq 0xc51(%rip), %rsi       # 0x4067
movb $0x0, %al
callq 0x2230
movl -0x8(%rbp), %edi
xorl %esi, %esi
callq 0x20f0
cmpl $0x0, %eax
jge 0x343f
movl $0x1, %edi
leaq 0xc2f(%rip), %rsi       # 0x4067
movb $0x0, %al
callq 0x2230
movl -0x8(%rbp), %edi
callq 0x2160
movl -0x4(%rbp), %edi
callq 0x2160
cmpq $0x0, 0x2dd9(%rip)      # 0x6230
je 0x3466
movq 0x2dd0(%rip), %rax      # 0x6230
movq %rax, -0x18(%rbp)
jmp 0x3473
leaq 0xcec(%rip), %rax       # 0x4159
movq %rax, -0x18(%rbp)
jmp 0x3473
movq -0x18(%rbp), %rcx
movq 0x2dba(%rip), %r9       # 0x6238
leaq 0xcc7(%rip), %rsi       # 0x414c
leaq 0xcca(%rip), %rdx       # 0x4156
leaq 0xcd4(%rip), %r8        # 0x4167
xorl %eax, %eax
movq %rsi, %rdi
movq $0x0, (%rsp)
movb $0x0, %al
callq 0x2390
movl $0x1, %edi
leaq 0xcb7(%rip), %rsi       # 0x416a
movb $0x0, %al
callq 0x2230
movl -0x4(%rbp), %edi
movl $0x1, %esi
callq 0x20f0
cmpl $0x0, %eax
jge 0x34df
movl $0x1, %edi
leaq 0xb8f(%rip), %rsi       # 0x4067
movb $0x0, %al
callq 0x2230
movl -0x4(%rbp), %edi
movl $0x2, %esi
callq 0x20f0
cmpl $0x0, %eax
jge 0x3504
movl $0x1, %edi
leaq 0xb6a(%rip), %rsi       # 0x4067
movb $0x0, %al
callq 0x2230
movl -0x8(%rbp), %edi
callq 0x2160
movl -0x4(%rbp), %edi
callq 0x2160
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)