// File: /workspace/github_c_makefile_star2_O2/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, %r15
cmpl $0x2, %edi
jl 0x14a8
movl %edi, %r14d
movq 0x8(%r15), %rdi
leaq 0x1fdc(%rip), %rsi      # 0x3466
callq 0x1050
testl %eax, %eax
jne 0x149f
leaq 0x1fd5(%rip), %rdi      # 0x346f
callq 0x1090
leal -0x19(%r14), %eax
cmpl $-0x15, %eax
ja 0x14b2
movq %r15, %rdi
xorl %esi, %esi
callq 0x13ac
movq 0x8(%r15), %rdi
pushq $0xa
popq %rbx
xorl %esi, %esi
movl %ebx, %edx
callq 0x1160
movq %rax, 0x18(%rsp)
movq 0x10(%r15), %rdi
xorl %esi, %esi
movl %ebx, %edx
callq 0x1160
movq %rax, 0x10(%rsp)
movq 0x18(%r15), %rdi
xorl %esi, %esi
movl %ebx, %edx
callq 0x1160
movq %rax, 0x8(%rsp)
leal -0x4(%r14), %ebx
movq %r15, (%rsp)
leaq 0x20(%r15), %r12
leaq 0x3c(%rsp), %r15
addb $-0x4, %r14b
movq %r14, 0x20(%rsp)
pushq $0x10
popq %r14
subl $0x1, %ebx
jb 0x1576
movq (%r12), %r13
movq %r13, %rdi
pushq $0x3d
popq %rsi
callq 0x10d0
testq %rax, %rax
je 0x15ff
movq %rax, %rbp
incq %rbp
movq %r13, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x1160
movb %al, (%r15)
movq %rbp, %rdi
leaq 0x28(%rsp), %rsi
movl %r14d, %edx
callq 0x1200
movq %rax, %rcx
movq 0x28(%rsp), %rax
subq %rbp, %rax
cqto
pushq $0x2
popq %rsi
idivq %rsi
incq %r15
subq $0x1, %rax
jb 0x1570
movb %cl, (%r15)
shrl $0x8, %ecx
jmp 0x155f
addq $0x8, %r12
jmp 0x1509
leaq 0x36(%rsp), %rax
movb $0x1, (%rax)
movq 0x8(%rsp), %rcx
movb %cl, 0x1(%rax)
movb %ch, 0x38(%rsp)
shrl $0x10, %ecx
movb %cl, 0x3(%rax)
movq 0x10(%rsp), %rcx
orb $-0x10, %cl
movb %cl, 0x4(%rax)
movq 0x20(%rsp), %rcx
movb %cl, 0x5(%rax)
subq %rax, %r15
leaq 0xa0(%rsp), %rdi
callq 0x16ec
leaq 0x1ebb(%rip), %rdi      # 0x3475
movq %rax, %rsi
movq 0x18(%rsp), %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x10e0
leaq 0x1eb8(%rip), %rbx      # 0x348b
xorl %r14d, %r14d
cmpq %r14, %r15
je 0x15f0
movzbl 0x36(%rsp,%r14), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10e0
incq %r14
jmp 0x15d6
pushq $0xa
popq %rdi
callq 0x1040
xorl %edi, %edi
callq 0x1210
movq (%rsp), %rdi
movq %r12, %rsi
callq 0x13ac
nop