// File: /workspace/github_c_makefile_star2_O2/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
andl $0x0, 0x18(%rsp)
andl $0x0, 0x14(%rsp)
andl $0x0, 0x10(%rsp)
andl $0x0, 0xc(%rsp)
andl $0x0, 0x8(%rsp)
movq %rsi, %rbx
andl $0x0, 0x4(%rsp)
movq %rdi, %r14
andl $0x0, 0x1c(%rsp)
leaq 0x14026(%rip), %rsi     # 0x31cc9
callq 0xd330
subq $0x8, %rsp
testq %rax, %rax
je 0x1dd3f
leaq 0x24(%rsp), %r10
leaq 0xc(%rsp), %r11
leaq 0x10(%rsp), %r15
leaq 0x14001(%rip), %rsi     # 0x31ccc
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 0x1dd82
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)
orl $-0x1, 0x20(%rdi)
callq 0xd250
jmp 0x1ddd8
leaq 0x24(%rsp), %r10
leaq 0xc(%rsp), %r11
leaq 0x10(%rsp), %r15
leaq 0x13fad(%rip), %rsi     # 0x31d02
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 0x1dd9a
leaq 0x13f59(%rip), %rdi     # 0x31ce2
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0x1bd48
jmp 0x1de2f
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)
orl $-0x1, 0x20(%rdi)
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 0x13f10(%rip), %rdi     # 0x31d17
movq %r14, %rsi
xorl %eax, %eax
pushq %r12
pushq %r11
pushq %r10
callq 0x1bd48
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
nopl (%rax)