// File: /workspace/github_c_makefile_star2_O2/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, %r14
movl %edi, %r12d
leal -0x1a(%r12), %eax
cmpl $-0x15, %eax
ja 0x146e
movq %r14, %rdi
xorl %esi, %esi
callq 0x138c
movq 0x8(%r14), %rdi
pushq $0xa
popq %rbx
xorl %esi, %esi
movl %ebx, %edx
callq 0x1140
movq %rax, 0x18(%rsp)
movq 0x10(%r14), %rdi
xorl %esi, %esi
movl %ebx, %edx
callq 0x1140
movq 0x18(%r14), %rdi
xorl %esi, %esi
movl %ebx, %edx
callq 0x1140
movq %rax, 0x10(%rsp)
movq 0x20(%r14), %rdi
xorl %esi, %esi
movl %ebx, %edx
callq 0x1140
movq %rax, 0x8(%rsp)
leal -0x5(%r12), %ebx
movq %r14, (%rsp)
addq $0x28, %r14
leaq 0x3c(%rsp), %r15
addb $-0x5, %r12b
movq %r12, 0x20(%rsp)
pushq $0x10
popq %r12
subl $0x1, %ebx
jb 0x153f
movq (%r14), %r13
movq %r13, %rdi
pushq $0x3d
popq %rsi
callq 0x10b0
testq %rax, %rax
je 0x15ca
movq %rax, %rbp
incq %rbp
movq %r13, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x1140
movb %al, (%r15)
movq %rbp, %rdi
leaq 0x28(%rsp), %rsi
movl %r12d, %edx
callq 0x11e0
movq %rax, %rcx
movq 0x28(%rsp), %rax
subq %rbp, %rax
cqto
pushq $0x2
popq %rsi
idivq %rsi
incq %r15
subq $0x1, %rax
jb 0x1539
movb %cl, (%r15)
shrl $0x8, %ecx
jmp 0x1528
addq $0x8, %r14
jmp 0x14d3
leaq 0x31(%rsp), %rax
movb $0x0, (%rax)
movq 0x10(%rsp), %rcx
movb %cl, 0x1(%rax)
movb %ch, 0x33(%rsp)
shrl $0x10, %ecx
movb %cl, 0x3(%rax)
movq 0x8(%rsp), %rcx
movl %ecx, 0x4(%rax)
andw $0x0, 0x8(%rax)
movq 0x20(%rsp), %rcx
movb %cl, 0xa(%rax)
subq %rax, %r15
leaq 0xa0(%rsp), %rdi
callq 0x16b8
leaq 0x1eec(%rip), %rdi      # 0x3471
movq %rax, %rsi
movq 0x18(%rsp), %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x10c0
leaq 0x1ee9(%rip), %rbx      # 0x3487
xorl %r14d, %r14d
cmpq %r14, %r15
je 0x15bb
movzbl 0x31(%rsp,%r14), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10c0
incq %r14
jmp 0x15a1
pushq $0xa
popq %rdi
callq 0x1040
xorl %edi, %edi
callq 0x11f0
movq (%rsp), %rdi
movq %r14, %rsi
callq 0x138c
nop