// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq $0x0, -0x40(%rbp)
cmpl $0x1, -0x14(%rbp)
jle 0x14d3
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x2fb2(%rip), %rsi      # 0x4466
callq 0x1040
cmpl $0x0, %eax
jne 0x14d3
leaq 0x3274(%rip), %rdi      # 0x4739
leaq 0x2fa3(%rip), %rsi      # 0x446f
movb $0x0, %al
callq 0x10c0
cmpl $0x5, -0x14(%rbp)
jl 0x14df
cmpl $0x18, -0x14(%rbp)
jle 0x14ec
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1390
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x1150
movq %rax, -0x28(%rbp)
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x1150
movq %rax, -0x38(%rbp)
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x1150
movq %rax, -0x30(%rbp)
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
leaq -0xaa(%rbp), %rax
addq $0x6, %rax
movq %rax, -0xd8(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x16d5
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movl $0x3d, %esi
callq 0x10b0
movq %rax, -0xc8(%rbp)
cmpq $0x0, -0xc8(%rbp)
je 0x16ac
movq -0xc8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc8(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x1150
movb %al, %cl
movq -0xd8(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0xd8(%rbp)
movb %cl, (%rax)
movq -0xc8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movl $0x10, %edx
callq 0x11f0
movl %eax, -0xdc(%rbp)
movq -0xd0(%rbp), %rax
movq -0xc8(%rbp), %rcx
subq %rcx, %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, -0xb8(%rbp)
cmpq $0x0, -0xb8(%rbp)
je 0x169e
movl -0xdc(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movq -0xd8(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0xd8(%rbp)
movb %cl, (%rax)
movl -0xdc(%rbp), %eax
shrl $0x8, %eax
movl %eax, -0xdc(%rbp)
movq -0xb8(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0xb8(%rbp)
jmp 0x164d
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x16b9
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x1390
jmp 0x16bb
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
jmp 0x159d
movb $0x1, -0xaa(%rbp)
movq -0x30(%rbp), %rax
andq $0xff, %rax
movb %al, -0xa9(%rbp)
movq -0x30(%rbp), %rax
sarq $0x8, %rax
andq $0xff, %rax
movb %al, -0xa8(%rbp)
movq -0x30(%rbp), %rax
sarq $0x10, %rax
movb %al, -0xa7(%rbp)
movq -0x38(%rbp), %rax
movb %al, %cl
movb -0xa6(%rbp), %al
andb $0xf, %cl
andb $-0x10, %al
orb %cl, %al
movb %al, -0xa6(%rbp)
movb -0xa6(%rbp), %al
andb $0xf, %al
orb $-0x10, %al
movb %al, -0xa6(%rbp)
movq -0x40(%rbp), %rax
movb %al, -0xa5(%rbp)
movq -0xd8(%rbp), %rax
leaq -0xaa(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0xc0(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x1940
movq %rax, %rsi
movq -0x28(%rbp), %rdx
movq -0xc0(%rbp), %rcx
leaq 0x2cfb(%rip), %rdi      # 0x4475
movb $0x0, %al
callq 0x10c0
movq $0x0, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
cmpq -0xc0(%rbp), %rax
jae 0x17cd
movq -0xb8(%rbp), %rax
movzbl -0xaa(%rbp,%rax), %esi
leaq 0x2cd9(%rip), %rdi      # 0x448b
movb $0x0, %al
callq 0x10c0
movq -0xb8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xb8(%rbp)
jmp 0x178c
leaq 0x2c90(%rip), %rdi      # 0x4464
movb $0x0, %al
callq 0x10c0
xorl %edi, %edi
callq 0x1200
nopw %cs:(%rax,%rax)
nopl (%rax)