// File: /workspace/github_c_makefile_star2_O0/arachsys[P]init/syslog.c
// Function: kernel_read
static void kernel_read(int fd) {
  char *cursor;
  int length, priority;
  struct tm date;
  time_t now;

  if ((length = read(fd, buffer, sizeof(buffer) - 1)) <= 0)
    return;

  time(&now);
  (zone && zone[0] ? localtime_r : gmtime_r)(&now, &date);

  for (cursor = buffer; cursor < buffer + length; cursor++)
    if (*cursor == 0 || *cursor == '\n')
      *cursor = 0;
    else if ((*cursor < 32 && *cursor != '\t') || *cursor == 127)
      *cursor = ' ';
  buffer[length] = 0;

  priority = strtoul(buffer, &cursor, 10);
  if (cursor == buffer)
    priority = LOG_KERN | LOG_NOTICE;

  cursor = strchr(buffer, ';');
  cursor = cursor ? cursor + 1 : buffer;

  if (*cursor) {
    if (numeric)
      printf("0 0 0 %u", priority & LOG_FACMASK);
    else
      printf("0 0 0 %s", syslog_facility(priority));
    printf(" %u %04u-%02u-%02u %02u:%02u:%02u", priority & LOG_PRIMASK,
      date.tm_year + 1900, date.tm_mon + 1, date.tm_mday, date.tm_hour,
      date.tm_min, date.tm_sec);
    if (zone && zone[0])
      printf("%c%02u%02u", date.tm_gmtoff < 0 ? '-' : '+',
        abs((int) date.tm_gmtoff) / 3600,
        abs((int) date.tm_gmtoff) / 60 % 60);
    printf(" %s\n", cursor);
    fflush(stdout);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movl %edi, -0x4(%rbp)
movl -0x4(%rbp), %edi
leaq 0x2dc8(%rip), %rsi      # 0x5360
movl $0x10000, %edx          # imm = 0x10000
callq 0x20b0
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
jg 0x25af
jmp 0x280b
leaq -0x58(%rbp), %rdi
callq 0x20f0
xorl %eax, %eax
cmpq $0x0, 0x2d96(%rip)      # 0x5358
movb %al, -0x59(%rbp)
je 0x25da
movq 0x2d8a(%rip), %rax      # 0x5358
movsbl (%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %dl
movq 0x29f4(%rip), %rax      # 0x4fd8
movq 0x29dd(%rip), %rcx      # 0x4fc8
testb $0x1, %dl
cmovneq %rcx, %rax
leaq -0x58(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq *%rax
leaq 0x2d5d(%rip), %rax      # 0x5360
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rdx
leaq 0x2d4a(%rip), %rcx      # 0x5360
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0x267c
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x2636
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
jne 0x263f
movq -0x10(%rbp), %rax
movb $0x0, (%rax)
jmp 0x266c
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x20, %eax
jge 0x2657
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x9, %eax
jne 0x2663
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x7f, %eax
jne 0x266a
movq -0x10(%rbp), %rax
movb $0x20, (%rax)
jmp 0x266c
jmp 0x266e
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x2607
movslq -0x14(%rbp), %rcx
leaq 0x2cd9(%rip), %rax      # 0x5360
movb $0x0, (%rax,%rcx)
leaq 0x2cce(%rip), %rdi      # 0x5360
leaq -0x10(%rbp), %rsi
movl $0xa, %edx
callq 0x2190
movl %eax, -0x18(%rbp)
leaq 0x2cb6(%rip), %rax      # 0x5360
cmpq %rax, -0x10(%rbp)
jne 0x26b7
movl $0x5, -0x18(%rbp)
leaq 0x2ca2(%rip), %rdi      # 0x5360
movl $0x3b, %esi
callq 0x2080
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x26e1
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x26ee
leaq 0x2c78(%rip), %rax      # 0x5360
movq %rax, -0x68(%rbp)
jmp 0x26ee
movq -0x68(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
je 0x280b
cmpl $0x0, 0x2c4a(%rip)      # 0x5354
je 0x2725
movl -0x18(%rbp), %esi
andl $0x3f8, %esi            # imm = 0x3F8
leaq 0xa7c(%rip), %rdi       # 0x3198
movb $0x0, %al
callq 0x2090
jmp 0x273e
movl -0x18(%rbp), %edi
callq 0x2b50
movq %rax, %rsi
leaq 0xa6a(%rip), %rdi       # 0x31a1
movb $0x0, %al
callq 0x2090
movl -0x18(%rbp), %esi
andl $0x7, %esi
movl -0x3c(%rbp), %edx
addl $0x76c, %edx            # imm = 0x76C
movl -0x40(%rbp), %ecx
addl $0x1, %ecx
movl -0x44(%rbp), %r8d
movl -0x48(%rbp), %r9d
movl -0x4c(%rbp), %r10d
movl -0x50(%rbp), %eax
leaq 0xa41(%rip), %rdi       # 0x31aa
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x2090
cmpq $0x0, 0x2bd8(%rip)      # 0x5358
je 0x27ea
movq 0x2bcf(%rip), %rax      # 0x5358
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x27ea
movq -0x28(%rbp), %rcx
movl $0x2b, %esi
movl $0x2d, %eax
cmpq $0x0, %rcx
cmovll %eax, %esi
movq -0x28(%rbp), %rax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movl $0xe10, %ecx            # imm = 0xE10
cltd
idivl %ecx
movl %eax, -0x6c(%rbp)
movq -0x28(%rbp), %rax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movl $0x3c, %ecx
cltd
idivl %ecx
movl $0x3c, %ecx
cltd
idivl %ecx
movl %edx, %ecx
movl -0x6c(%rbp), %edx
leaq 0x9e9(%rip), %rdi       # 0x31cc
movb $0x0, %al
callq 0x2090
movq -0x10(%rbp), %rsi
leaq 0x9e2(%rip), %rdi       # 0x31d7
movb $0x0, %al
callq 0x2090
movq 0x27bd(%rip), %rax      # 0x4fc0
movq (%rax), %rdi
callq 0x2110
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)