// File: /workspace/github_c_makefile_star2_O1/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, %r14
movl %edi, %r13d
cmpl $0x2, %edi
jl 0x14ae
movq 0x8(%r14), %rdi
leaq 0x1fcd(%rip), %rsi      # 0x3466
callq 0x1050
testl %eax, %eax
jne 0x14ae
leaq 0x1fc6(%rip), %rdi      # 0x346f
callq 0x1090
leal -0x19(%r13), %eax
cmpl $-0x15, %eax
ja 0x14c1
movq %r14, %rdi
xorl %esi, %esi
callq 0x13ac
movq 0x8(%r14), %rdi
movq $0x0, (%rsp)
xorl %esi, %esi
movl $0xa, %edx
callq 0x1160
movq %rax, %r12
movq 0x10(%r14), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1160
movq %rax, 0x20(%rsp)
movq 0x18(%r14), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1160
movl %r13d, %ebx
leaq 0x3c(%rsp), %r15
addl $-0x4, %ebx
je 0x15b6
movq %rax, 0x8(%rsp)
movq %r12, 0x10(%rsp)
movq %r14, 0x18(%rsp)
leaq 0x20(%r14), %r12
addb $-0x4, %r13b
movq %r13, (%rsp)
leaq 0x28(%rsp), %r13
movq (%r12), %r14
movq %r14, %rdi
movl $0x3d, %esi
callq 0x10d0
testq %rax, %rax
je 0x1643
movq %rax, %rbp
incq %rbp
movq %r14, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1160
movb %al, (%r15)
movq %rbp, %rdi
movq %r13, %rsi
movl $0x10, %edx
callq 0x1200
movq 0x28(%rsp), %rdx
subq %rbp, %rdx
incq %r15
leaq 0x1(%rdx), %rcx
cmpq $0x3, %rcx
jb 0x15a4
movq %rdx, %rcx
shrq $0x3f, %rcx
addq %rdx, %rcx
sarq %rcx
movb %al, (%r15)
shrl $0x8, %eax
incq %r15
decq %rcx
jne 0x1596
addq $0x8, %r12
decl %ebx
jne 0x1532
movq 0x10(%rsp), %r12
movq 0x8(%rsp), %rax
leaq 0x36(%rsp), %rbx
movb $0x1, (%rbx)
movb %al, 0x1(%rbx)
movb %ah, 0x38(%rsp)
shrl $0x10, %eax
movb %al, 0x3(%rbx)
movq 0x20(%rsp), %rax
orb $-0x10, %al
movb %al, 0x4(%rbx)
movq (%rsp), %rax
movb %al, 0x5(%rbx)
leaq 0xa0(%rsp), %rdi
callq 0x1759
leaq 0x1e85(%rip), %rdi      # 0x3475
movq %r15, %rcx
subq %rbx, %rcx
movq %rax, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x10e0
subq %rbx, %r15
je 0x1632
cmpq $0x1, %r15
adcq $0x0, %r15
leaq 0x1e74(%rip), %rbx      # 0x348b
xorl %r14d, %r14d
movzbl 0x36(%rsp,%r14), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10e0
incq %r14
cmpq %r14, %r15
jne 0x161a
movl $0xa, %edi
callq 0x1040
xorl %edi, %edi
callq 0x1210
movq 0x18(%rsp), %rdi
movq %r12, %rsi
callq 0x13ac