// File: /workspace/github_c_makefile_star2_O1/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, %r13
movl %edi, %ebp
leal -0x1a(%rbp), %eax
cmpl $-0x15, %eax
ja 0x147a
movq %r13, %rdi
xorl %esi, %esi
callq 0x138c
movq 0x8(%r13), %rdi
xorl %r12d, %r12d
xorl %esi, %esi
movl $0xa, %edx
callq 0x1140
movq %rax, %r15
movq 0x10(%r13), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1140
movq 0x18(%r13), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1140
movq %rax, 0x20(%rsp)
movq 0x20(%r13), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1140
movl %ebp, %ebx
leaq 0x3c(%rsp), %r14
addl $-0x5, %ebx
je 0x157d
movq %rax, (%rsp)
movq %r15, 0x10(%rsp)
movq %r13, 0x18(%rsp)
addq $0x28, %r13
addb $-0x5, %bpl
movq %rbp, 0x8(%rsp)
leaq 0x28(%rsp), %rbp
movq (%r13), %r12
movq %r12, %rdi
movl $0x3d, %esi
callq 0x10b0
testq %rax, %rax
je 0x160b
movq %rax, %r15
incq %r15
movq %r12, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1140
movb %al, (%r14)
movq %r15, %rdi
movq %rbp, %rsi
movl $0x10, %edx
callq 0x11e0
movq 0x28(%rsp), %rdx
subq %r15, %rdx
incq %r14
leaq 0x1(%rdx), %rcx
cmpq $0x3, %rcx
jb 0x1567
movq %rdx, %rcx
shrq $0x3f, %rcx
addq %rdx, %rcx
sarq %rcx
movb %al, (%r14)
shrl $0x8, %eax
incq %r14
decq %rcx
jne 0x1559
addq $0x8, %r13
decl %ebx
jne 0x14f5
movq 0x10(%rsp), %r15
movq 0x8(%rsp), %r12
movq (%rsp), %rax
leaq 0x31(%rsp), %rbx
movb $0x0, (%rbx)
movq 0x20(%rsp), %rcx
movb %cl, 0x1(%rbx)
movb %ch, 0x33(%rsp)
shrl $0x10, %ecx
movb %cl, 0x3(%rbx)
movl %eax, 0x4(%rbx)
movw $0x0, 0x8(%rbx)
movb %r12b, 0xa(%rbx)
leaq 0xa0(%rsp), %rdi
callq 0x1721
leaq 0x1eb9(%rip), %rdi      # 0x3471
movq %r14, %rcx
subq %rbx, %rcx
movq %rax, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x10c0
subq %rbx, %r14
je 0x15fa
cmpq $0x1, %r14
adcq $0x0, %r14
leaq 0x1ea8(%rip), %rbx      # 0x3487
xorl %r15d, %r15d
movzbl 0x31(%rsp,%r15), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10c0
incq %r15
cmpq %r15, %r14
jne 0x15e2
movl $0xa, %edi
callq 0x1040
xorl %edi, %edi
callq 0x11f0
movq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x138c