// File: /workspace/github_c_makefile_star2_O3/canboat[P]canboat/group-function/command.c
// Function: main
int main(int argc, char **argv)
{
  int                      ac = argc;
  char                   **av = argv;
  long                     dest;
  long                     pgn;
  long                     prio;
  size_t                   cnt = 0;
  command_group_function_t command;
  size_t                   i, bytes;
  char                    *p, *e;
  uint8_t                 *b;
  uint32_t                 v;
  char                     dateStr[DATE_LENGTH];

  if (ac > 1 && strcasecmp(av[1], "-version") == 0)
  {
    printf("%s\n", VERSION);
  }
  if (ac < 5 || ac > 4 + MAX_FIELDS)
  {
    usage(argv, 0);
  }

  ac--, av++; /* lose the command name */
  dest = strtol(av[0], 0, 10);
  ac--, av++; /* lose the dest */
  prio = strtol(av[0], 0, 10);
  ac--, av++; /* lose the prio */
  pgn = strtol(av[0], 0, 10);
  ac--, av++; /* lose the pgn */
  b = &command.parameters[0];

  for (; ac; ac--, av++)
  {
    p = strchr(av[0], '=');
    if (p)
    {
      p++;
      *b++ = strtol(av[0], 0, 10);

      v = strtoul(p, &e, 16);
      for (i = (e - p) / 2; i; i--)
      {
        *b++ = (v & 255);
        v    = v >> 8;
      }

      cnt++;
    }
    else
    {
      usage(argv, av);
    }
  }

  command.functionCode = 1;
  command.pgn[0]       = (pgn) & 0xff;
  command.pgn[1]       = (pgn >> 8) & 0xff;
  command.pgn[2]       = (pgn >> 16);
  command.priority     = prio;
  command.reserved     = -1;
  command.count        = cnt;

  bytes = b - (uint8_t *) &command;
  printf("%s,2,126208,0,%lu,%zu", fmtNow(dateStr), dest, bytes);
  for (i = 0; i < bytes; i++)
  {
    printf(",%02x", ((unsigned char *) &command)[i]);
  }
  printf("\n");
  exit(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rsi, %r12
cmpl $0x2, %edi
jl 0x14b8
movl %edi, %r15d
movq 0x8(%r12), %rdi
leaq 0x1fcc(%rip), %rsi      # 0x3466
callq 0x1050
testl %eax, %eax
jne 0x14af
leaq 0x1fc5(%rip), %rdi      # 0x346f
callq 0x1090
leal -0x19(%r15), %eax
cmpl $-0x15, %eax
ja 0x14c2
movq %r12, %rdi
xorl %esi, %esi
callq 0x13ac
movq 0x8(%r12), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1160
movq %rax, 0x10(%rsp)
movq 0x10(%r12), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1160
movq %rax, 0x8(%rsp)
movq 0x18(%r12), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1160
movq %rax, (%rsp)
leal -0x4(%r15), %ebx
leaq 0x3c(%rsp), %r14
movq %r12, 0x20(%rsp)
leaq 0x20(%r12), %r13
addb $-0x4, %r15b
movq %r15, 0x18(%rsp)
leaq 0x28(%rsp), %rbp
movq (%r13), %r12
movq %r12, %rdi
movl $0x3d, %esi
callq 0x10d0
testq %rax, %rax
je 0x1632
movq %rax, %r15
incq %r15
movq %r12, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1160
movb %al, (%r14)
movq %r15, %rdi
movq %rbp, %rsi
movl $0x10, %edx
callq 0x1200
movq 0x28(%rsp), %rdx
subq %r15, %rdx
incq %r14
leaq 0x1(%rdx), %rcx
cmpq $0x3, %rcx
jb 0x1596
movq %rdx, %rcx
shrq $0x3f, %rcx
addq %rdx, %rcx
sarq %rcx
movb %al, (%r14)
shrl $0x8, %eax
incq %r14
decq %rcx
jne 0x1588
addq $0x8, %r13
decl %ebx
jne 0x1524
leaq 0x36(%rsp), %rbx
movb $0x1, (%rbx)
movq (%rsp), %rax
movb %al, 0x1(%rbx)
movb %ah, 0x38(%rsp)
shrl $0x10, %eax
movb %al, 0x3(%rbx)
movq 0x8(%rsp), %rax
orb $-0x10, %al
movb %al, 0x4(%rbx)
movq 0x18(%rsp), %rax
movb %al, 0x5(%rbx)
leaq 0xa0(%rsp), %rdi
callq 0x1749
leaq 0x1e98(%rip), %rdi      # 0x3475
movq %r14, %rcx
subq %rbx, %rcx
movq %rax, %rsi
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x10e0
subq %rbx, %r14
je 0x1621
cmpq $0x1, %r14
adcq $0x0, %r14
leaq 0x1e85(%rip), %rbx      # 0x348b
xorl %r15d, %r15d
movzbl 0x36(%rsp,%r15), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10e0
incq %r15
cmpq %r15, %r14
jne 0x1609
movl $0xa, %edi
callq 0x1040
xorl %edi, %edi
callq 0x1210
movq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0x13ac
nop