// File: /workspace/github_c_makefile_star2_O1/canboat[P]canboat/analyzer/../common/parse.c
// Function: parseTimestamp
bool parseTimestamp(const char *msg, uint64_t *when)
{
  struct tm t;
  time_t    epoch;
  int       year  = 0;
  int       month = 0;
  int       day   = 0;
  int       hour  = 0;
  int       min   = 0;
  int       sec   = 0;
  int       milli = 0;
  char     *p;

  p = strstr(msg, "Z,");
  if (p)
  {
    if (sscanf(msg, "%d-%d-%dT%d:%d:%d.%dZ", &year, &month, &day, &hour, &min, &sec, &milli) < 6)
    {
      logDebug("Unable to parse timestamp '%s'\n", msg);
      return false;
    }
    t.tm_year  = year - 1900;
    t.tm_mon   = month - 1;
    t.tm_mday  = day;
    t.tm_hour  = hour;
    t.tm_min   = min;
    t.tm_sec   = sec;
    t.tm_isdst = -1;
    epoch      = timegm(&t);
  }
  else
  {
    if (sscanf(msg, "%d-%d-%d %d:%d:%d.%d", &year, &month, &day, &hour, &min, &sec, &milli) < 6)
    {
      logDebug("Unable to parse timestamp '%s'\n", msg);
      return false;
    }
    t.tm_year  = year - 1900;
    t.tm_mon   = month - 1;
    t.tm_mday  = day;
    t.tm_hour  = hour;
    t.tm_min   = min;
    t.tm_sec   = sec;
    t.tm_isdst = -1;
    epoch      = mktime(&t);
  }

  logDebug("parseTimestamp '%s' => %d-%d-%d %d:%d:%d.%03d\n", msg, year, month, day, hour, min, sec, milli);

  *when = epoch * UINT64_C(1000) + milli;

  return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %rbx
movq %rdi, %r14
xorl %eax, %eax
movl %eax, 0x18(%rsp)
movl %eax, 0x14(%rsp)
movl %eax, 0x10(%rsp)
movl %eax, 0xc(%rsp)
movl %eax, 0x8(%rsp)
movl %eax, 0x4(%rsp)
movl %eax, 0x1c(%rsp)
leaq 0x188f8(%rip), %rsi     # 0x3ff2c
callq 0xd330
subq $0x8, %rsp
testq %rax, %rax
je 0x276d3
leaq 0x24(%rsp), %r10
leaq 0xc(%rsp), %r11
leaq 0x10(%rsp), %r15
leaq 0x188d3(%rip), %rsi     # 0x3ff2f
leaq 0x20(%rsp), %rdx
leaq 0x1c(%rsp), %rcx
leaq 0x18(%rsp), %r8
leaq 0x14(%rsp), %r9
movq %r14, %rdi
xorl %eax, %eax
pushq %r10
pushq %r11
pushq %r15
callq 0xd220
addq $0x20, %rsp
cmpl $0x5, %eax
jle 0x27716
movl $0xfffff894, %eax       # imm = 0xFFFFF894
addl 0x18(%rsp), %eax
leaq 0x20(%rsp), %rdi
movl %eax, 0x14(%rdi)
movl 0x14(%rsp), %eax
decl %eax
movl %eax, 0x10(%rdi)
movl 0x10(%rsp), %eax
movl %eax, 0xc(%rdi)
movl 0xc(%rsp), %eax
movl %eax, 0x8(%rdi)
movl 0x8(%rsp), %eax
movl %eax, 0x4(%rdi)
movl 0x4(%rsp), %eax
movl %eax, (%rdi)
movl $0xffffffff, 0x20(%rdi) # imm = 0xFFFFFFFF
callq 0xd250
jmp 0x2776f
leaq 0x24(%rsp), %r10
leaq 0xc(%rsp), %r11
leaq 0x10(%rsp), %r15
leaq 0x1887c(%rip), %rsi     # 0x3ff65
leaq 0x20(%rsp), %rdx
leaq 0x1c(%rsp), %rcx
leaq 0x18(%rsp), %r8
leaq 0x14(%rsp), %r9
movq %r14, %rdi
xorl %eax, %eax
pushq %r10
pushq %r11
pushq %r15
callq 0xd220
addq $0x20, %rsp
cmpl $0x5, %eax
jg 0x2772e
leaq 0x18828(%rip), %rdi     # 0x3ff45
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0x254dd
jmp 0x277c6
movl $0xfffff894, %eax       # imm = 0xFFFFF894
addl 0x18(%rsp), %eax
leaq 0x20(%rsp), %rdi
movl %eax, 0x14(%rdi)
movl 0x14(%rsp), %eax
decl %eax
movl %eax, 0x10(%rdi)
movl 0x10(%rsp), %eax
movl %eax, 0xc(%rdi)
movl 0xc(%rsp), %eax
movl %eax, 0x8(%rdi)
movl 0x8(%rsp), %eax
movl %eax, 0x4(%rdi)
movl 0x4(%rsp), %eax
movl %eax, (%rdi)
movl $0xffffffff, 0x20(%rdi) # imm = 0xFFFFFFFF
callq 0xd230
movq %rax, %r15
movl 0x18(%rsp), %edx
movl 0x14(%rsp), %ecx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
movl 0x8(%rsp), %r10d
movl 0x4(%rsp), %r11d
movl 0x1c(%rsp), %r12d
subq $0x8, %rsp
leaq 0x187dc(%rip), %rdi     # 0x3ff7a
movq %r14, %rsi
xorl %eax, %eax
pushq %r12
pushq %r11
pushq %r10
callq 0x254dd
addq $0x20, %rsp
imulq $0x3e8, %r15, %rax      # imm = 0x3E8
movslq 0x1c(%rsp), %rcx
addq %rax, %rcx
movq %rcx, (%rbx)
movb $0x1, %bl
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq