// File: /workspace/github_c_makefile_star2_O0/canboat[P]canboat/replay/replay.c
// Function: main
int main(int argc, char **argv)
{
  char      line[8192];
  struct tm tm;
  char     *r;
  int       ms;
  uint64_t  now;
  uint64_t  prev = UINT64_C(0);

  setProgName(argv[0]);
  while (argc > 1)
  {
    if (strcasecmp(argv[1], "-version") == 0)
    {
      printf("%s\n", VERSION);
      exit(0);
    }
    else if (strcasecmp(argv[1], "-d") == 0)
    {
      setLogLevel(LOGLEVEL_DEBUG);
    }
    argc--;
    argv++;
  }

  while (fgets(line, sizeof(line), stdin))
  {
    memset(&tm, 0, sizeof(tm));
    ms = 0;

    r = strptime(line, FORMAT_DT, &tm);
    if (r)
    {
      sscanf(r + 1, FORMAT_MS, &ms);
    }
    now = timegm(&tm);
    logDebug("%-1.24s = %" PRIu64 " s r='%-1.10s'\n", line, now, r);
    now = now * UINT64_C(1000) + ms;
    logDebug("%-1.24s = %" PRIu64 " ms\n", line, now);

    if (now > prev && now < prev + UINT64_C(10000))
    {
      uint64_t       diff    = now - prev;
      struct timeval timeout = {diff / UINT64_C(1000), (diff % UINT64_C(1000)) * UINT64_C(1000)};

      logDebug("%-1.24s = %" PRIu64 " zzz=%" PRIu64 "\n", line, now, diff);
      select(1, NULL, NULL, NULL, &timeout);
    }
    else
    {
      logDebug("%-1.24s = %" PRIu64 "\n", line, now);
    }
    prev = now;

    fprintf(stdout, "%s", line);
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2080, %rsp           # imm = 0x2080
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x2068(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2c60
cmpl $0x1, -0x8(%rbp)
jle 0x2457
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x2c0f(%rip), %rsi      # 0x5004
callq 0x2040
cmpl $0x0, %eax
jne 0x241b
leaq 0x2f11(%rip), %rdi      # 0x5317
leaq 0x2c00(%rip), %rsi      # 0x500d
movb $0x0, %al
callq 0x20c0
xorl %edi, %edi
callq 0x2210
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x2be9(%rip), %rsi      # 0x5013
callq 0x2040
cmpl $0x0, %eax
jne 0x243e
movl $0x3, %edi
callq 0x2bc0
jmp 0x2440
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
jmp 0x23e0
jmp 0x2459
leaq -0x2010(%rbp), %rdi
movq 0x4b71(%rip), %rax      # 0x6fd8
movq (%rax), %rdx
movl $0x2000, %esi           # imm = 0x2000
callq 0x2140
cmpq $0x0, %rax
je 0x2660
leaq -0x2048(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x2120
movl $0x0, -0x2054(%rbp)
leaq -0x2010(%rbp), %rdi
leaq 0x2b6d(%rip), %rsi      # 0x5016
leaq -0x2048(%rbp), %rdx
callq 0x2250
movq %rax, -0x2050(%rbp)
cmpq $0x0, -0x2050(%rbp)
je 0x24e6
movq -0x2050(%rbp), %rdi
addq $0x1, %rdi
leaq 0x2b50(%rip), %rsi      # 0x5028
leaq -0x2054(%rbp), %rdx
movb $0x0, %al
callq 0x21b0
leaq -0x2048(%rbp), %rdi
callq 0x21d0
movq %rax, -0x2060(%rbp)
leaq -0x2010(%rbp), %rsi
movq -0x2060(%rbp), %rdx
movq -0x2050(%rbp), %rcx
leaq 0x2b16(%rip), %rdi      # 0x502b
movb $0x0, %al
callq 0x2930
imulq $0x3e8, -0x2060(%rbp), %rax # imm = 0x3E8
movslq -0x2054(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x2060(%rbp)
leaq -0x2010(%rbp), %rsi
movq -0x2060(%rbp), %rdx
leaq 0x2afb(%rip), %rdi      # 0x5048
movb $0x0, %al
callq 0x2930
movq -0x2060(%rbp), %rax
cmpq -0x2068(%rbp), %rax
jbe 0x2612
movq -0x2060(%rbp), %rax
movq -0x2068(%rbp), %rcx
addq $0x2710, %rcx           # imm = 0x2710
cmpq %rcx, %rax
jae 0x2612
movq -0x2060(%rbp), %rax
subq -0x2068(%rbp), %rax
movq %rax, -0x2070(%rbp)
movq -0x2070(%rbp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %edx, %edx
divq %rcx
movq %rax, -0x2080(%rbp)
movq -0x2070(%rbp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %edx, %edx
divq %rcx
imulq $0x3e8, %rdx, %rax      # imm = 0x3E8
movq %rax, -0x2078(%rbp)
leaq -0x2010(%rbp), %rsi
movq -0x2060(%rbp), %rdx
movq -0x2070(%rbp), %rcx
leaq 0x2a6c(%rip), %rdi      # 0x505a
movb $0x0, %al
callq 0x2930
movl $0x1, %edi
xorl %eax, %eax
movl %eax, %ecx
leaq -0x2080(%rbp), %r8
movq %rcx, %rsi
movq %rcx, %rdx
callq 0x2180
jmp 0x262e
leaq -0x2010(%rbp), %rsi
movq -0x2060(%rbp), %rdx
leaq 0x2a4a(%rip), %rdi      # 0x5071
movb $0x0, %al
callq 0x2930
movq -0x2060(%rbp), %rax
movq %rax, -0x2068(%rbp)
movq 0x498d(%rip), %rax      # 0x6fd0
movq (%rax), %rdi
leaq -0x2010(%rbp), %rdx
leaq 0x2a2c(%rip), %rsi      # 0x5080
movb $0x0, %al
callq 0x2150
jmp 0x2459
xorl %eax, %eax
addq $0x2080, %rsp           # imm = 0x2080
popq %rbp
retq
nopl (%rax,%rax)