// File: /workspace/github_c_makefile_star2_O0/arachsys[P]init/daemon.c
// Function: logger_setup
static void logger_setup(const char *spec) {
  int status;
  pid_t pid;

  if (logger.tag)
    errx(EXIT_FAILURE, "-l cannot be specified more than once");
  if (!*spec || *spec == ':')
    errx(EXIT_FAILURE, "Invalid or missing syslog identifier tag");
  if (!(logger.tag = strdup(spec)))
    err(EXIT_FAILURE, "strdup");

  /* Logging to file indicated by absolute path. */
  if (*logger.tag == '/') {
    logger.fd = open(logger.tag, O_RDWR | O_APPEND | O_CREAT, 0666);
    if (logger.fd < 0)
      err(EXIT_FAILURE, "%s", logger.tag);
    if (flock(logger.fd, LOCK_EX | LOCK_NB) < 0)
      errx(EXIT_FAILURE, "%s already locked", logger.tag);
    return;
  }

  /* Log spec format is TAG:PRIORITY. */
  if ((logger.priority = strchr(logger.tag, ':'))) {
    *logger.priority++ = 0;
    if (!*logger.priority)
      logger.priority = NULL;
  }

  /* Test the logger settings so we can exit early if they are invalid. */
  switch (pid = fork()) {
    case -1:
      err(EXIT_FAILURE, "fork");
    case 0:
      if (chdir("/") < 0)
        err(EXIT_FAILURE, "chdir");
      execlp("logger", "logger", "-f", "/dev/null",
          "-p", logger.priority ? logger.priority : "daemon.notice",
          "-t", logger.tag, NULL);
      err(EXIT_FAILURE, "exec");
  }

  if (waitpid(pid, &status, 0) < 0)
    err(EXIT_FAILURE, "waitpid");

  /* The logger subprocess writes its own message to stderr on failure. */
  if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
    exit(EXIT_FAILURE);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, 0x36d4(%rip)      # 0x6238
je 0x2b79
movl $0x1, %edi
leaq 0x1579(%rip), %rsi      # 0x40eb
movb $0x0, %al
callq 0x20e0
movq -0x8(%rbp), %rax
cmpb $0x0, (%rax)
je 0x2b8e
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
jne 0x2ba1
movl $0x1, %edi
leaq 0x1577(%rip), %rsi      # 0x4111
movb $0x0, %al
callq 0x20e0
movq -0x8(%rbp), %rdi
callq 0x2380
movq %rax, 0x3687(%rip)      # 0x6238
cmpq $0x0, %rax
jne 0x2bca
movl $0x1, %edi
leaq 0x1515(%rip), %rsi      # 0x40d8
movb $0x0, %al
callq 0x2230
movq 0x3667(%rip), %rax      # 0x6238
movsbl (%rax), %eax
cmpl $0x2f, %eax
jne 0x2c4e
movq 0x3658(%rip), %rdi      # 0x6238
movl $0x442, %esi            # imm = 0x442
movl $0x1b6, %edx            # imm = 0x1B6
movb $0x0, %al
callq 0x22e0
movl %eax, 0x3649(%rip)      # 0x6240
cmpl $0x0, 0x3642(%rip)      # 0x6240
jge 0x2c1a
movq 0x3631(%rip), %rdx      # 0x6238
movl $0x1, %edi
leaq 0x15e2(%rip), %rsi      # 0x41f5
movb $0x0, %al
callq 0x2230
movl 0x3620(%rip), %edi      # 0x6240
movl $0x6, %esi
callq 0x2320
cmpl $0x0, %eax
jge 0x2c49
movq 0x3602(%rip), %rdx      # 0x6238
movl $0x1, %edi
leaq 0x14f8(%rip), %rsi      # 0x413a
movb $0x0, %al
callq 0x20e0
jmp 0x2dc2
movq 0x35e3(%rip), %rdi      # 0x6238
movl $0x3a, %esi
callq 0x2100
movq %rax, 0x35ca(%rip)      # 0x6230
cmpq $0x0, %rax
je 0x2c9d
movq 0x35bd(%rip), %rax      # 0x6230
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x35af(%rip)      # 0x6230
movb $0x0, (%rax)
movq 0x35a5(%rip), %rax      # 0x6230
cmpb $0x0, (%rax)
jne 0x2c9b
movq $0x0, 0x3595(%rip) # 0x6230
jmp 0x2c9d
callq 0x23c0
movl %eax, -0x10(%rbp)
movl %eax, %ecx
movl %ecx, -0x14(%rbp)
subl $-0x1, %eax
je 0x2cbd
jmp 0x2cb1
movl -0x14(%rbp), %eax
testl %eax, %eax
je 0x2cd0
jmp 0x2d77
movl $0x1, %edi
leaq 0x13f1(%rip), %rsi      # 0x40ba
movb $0x0, %al
callq 0x2230
leaq 0x19fb(%rip), %rdi      # 0x46d2
callq 0x20d0
cmpl $0x0, %eax
jge 0x2cf4
movl $0x1, %edi
leaq 0x13f3(%rip), %rsi      # 0x40e0
movb $0x0, %al
callq 0x2230
cmpq $0x0, 0x3534(%rip)      # 0x6230
je 0x2d0b
movq 0x352b(%rip), %rax      # 0x6230
movq %rax, -0x20(%rbp)
jmp 0x2d18
leaq 0x1447(%rip), %rax      # 0x4159
movq %rax, -0x20(%rbp)
jmp 0x2d18
movq -0x20(%rbp), %r9
movq 0x3515(%rip), %rax      # 0x6238
leaq 0x1422(%rip), %rsi      # 0x414c
leaq 0x1422(%rip), %rdx      # 0x4153
leaq 0x1325(%rip), %rcx      # 0x405d
leaq 0x1417(%rip), %r8       # 0x4156
leaq 0x1421(%rip), %r10      # 0x4167
xorl %edi, %edi
movq %rsi, %rdi
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movb $0x0, %al
callq 0x2390
movl $0x1, %edi
leaq 0x13fa(%rip), %rsi      # 0x416a
movb $0x0, %al
callq 0x2230
movl -0x10(%rbp), %edi
leaq -0xc(%rbp), %rsi
xorl %edx, %edx
callq 0x22d0
cmpl $0x0, %eax
jge 0x2d9d
movl $0x1, %edi
leaq 0x13d9(%rip), %rsi      # 0x416f
movb $0x0, %al
callq 0x2230
movl -0xc(%rbp), %eax
andl $0x7f, %eax
cmpl $0x0, %eax
jne 0x2db8
movl -0xc(%rbp), %eax
andl $0xff00, %eax           # imm = 0xFF00
sarl $0x8, %eax
cmpl $0x0, %eax
je 0x2dc2
movl $0x1, %edi
callq 0x2350
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)