// File: /workspace/github_c_makefile_star2_O3/canboat[P]canboat/group-function/request.c
// Function: main
int main(int argc, char **argv)
{
  int                      ac = argc;
  char                   **av = argv;
  long                     dest;
  long                     pgn;
  long                     interval;
  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 < 6 || ac > 5 + MAX_FIELDS)
  {
    usage(argv, 0);
  }

  ac--, av++; /* lose the command name */
  dest = strtol(av[0], 0, 10);
  ac--, av++; /* lose the dest */
  /* ignore */ strtol(av[0], 0, 10);
  ac--, av++; /* lose the prio */
  pgn = strtol(av[0], 0, 10);
  ac--, av++; /* lose the pgn */
  interval = strtol(av[0], 0, 10);
  ac--, av++; /* lose the interval */
  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 = 0;
  command.pgn[0]       = (pgn) & 0xff;
  command.pgn[1]       = (pgn >> 8) & 0xff;
  command.pgn[2]       = (pgn >> 16);
  command.interval     = interval;
  command.offset       = 0;
  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
movl %edi, %r14d
leal -0x1a(%r14), %eax
cmpl $-0x15, %eax
ja 0x147c
movq %r12, %rdi
xorl %esi, %esi
callq 0x138c
movq 0x8(%r12), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1140
movq %rax, 0x10(%rsp)
movq 0x10(%r12), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1140
movq 0x18(%r12), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1140
movq %rax, 0x8(%rsp)
movq 0x20(%r12), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1140
movq %rax, (%rsp)
leal -0x5(%r14), %ebx
leaq 0x3c(%rsp), %r15
movq %r12, 0x20(%rsp)
leaq 0x28(%r12), %r13
addb $-0x5, %r14b
movq %r14, 0x18(%rsp)
leaq 0x28(%rsp), %rbp
movq (%r13), %r12
movq %r12, %rdi
movl $0x3d, %esi
callq 0x10b0
testq %rax, %rax
je 0x1601
movq %rax, %r14
incq %r14
movq %r12, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1140
movb %al, (%r15)
movq %r14, %rdi
movq %rbp, %rsi
movl $0x10, %edx
callq 0x11e0
movq 0x28(%rsp), %rdx
subq %r14, %rdx
incq %r15
leaq 0x1(%rdx), %rcx
cmpq $0x3, %rcx
jb 0x1561
movq %rdx, %rcx
shrq $0x3f, %rcx
addq %rdx, %rcx
sarq %rcx
movb %al, (%r15)
shrl $0x8, %eax
incq %r15
decq %rcx
jne 0x1553
addq $0x8, %r13
decl %ebx
jne 0x14ef
leaq 0x31(%rsp), %rbx
movb $0x0, (%rbx)
movq 0x8(%rsp), %rax
movb %al, 0x1(%rbx)
movb %ah, 0x33(%rsp)
shrl $0x10, %eax
movb %al, 0x3(%rbx)
movq (%rsp), %rax
movl %eax, 0x4(%rbx)
movw $0x0, 0x8(%rbx)
movq 0x18(%rsp), %rax
movb %al, 0xa(%rbx)
leaq 0xa0(%rsp), %rdi
callq 0x1719
leaq 0x1ec5(%rip), %rdi      # 0x3471
movq %r15, %rcx
subq %rbx, %rcx
movq %rax, %rsi
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x10c0
subq %rbx, %r15
je 0x15f0
cmpq $0x1, %r15
adcq $0x0, %r15
leaq 0x1eb2(%rip), %rbx      # 0x3487
xorl %r14d, %r14d
movzbl 0x31(%rsp,%r14), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10c0
incq %r14
cmpq %r14, %r15
jne 0x15d8
movl $0xa, %edi
callq 0x1040
xorl %edi, %edi
callq 0x11f0
movq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0x138c
nop