// File: /workspace/github_c_makefile_star2_O0/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
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 $0x6, -0x14(%rbp)
jl 0x149b
cmpl $0x19, -0x14(%rbp)
jle 0x14a8
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1380
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 0x1140
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 0x1140
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 0x1140
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)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x1140
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)
leaq -0xaf(%rbp), %rax
addq $0xb, %rax
movq %rax, -0xd8(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x16bb
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movl $0x3d, %esi
callq 0x10a0
movq %rax, -0xc8(%rbp)
cmpq $0x0, -0xc8(%rbp)
je 0x1692
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 0x1140
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 0x11e0
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 0x1684
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 0x1633
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x169f
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x1380
jmp 0x16a1
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
jmp 0x1583
movb $0x0, -0xaf(%rbp)
movq -0x30(%rbp), %rax
andq $0xff, %rax
movb %al, -0xae(%rbp)
movq -0x30(%rbp), %rax
sarq $0x8, %rax
andq $0xff, %rax
movb %al, -0xad(%rbp)
movq -0x30(%rbp), %rax
sarq $0x10, %rax
movb %al, -0xac(%rbp)
movq -0x38(%rbp), %rax
movl %eax, -0xab(%rbp)
movw $0x0, -0xa7(%rbp)
movq -0x40(%rbp), %rax
movb %al, -0xa5(%rbp)
movq -0xd8(%rbp), %rax
leaq -0xaf(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0xc0(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x1910
movq %rax, %rsi
movq -0x28(%rbp), %rdx
movq -0xc0(%rbp), %rcx
leaq 0x2d27(%rip), %rdi      # 0x4471
movb $0x0, %al
callq 0x10b0
movq $0x0, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
cmpq -0xc0(%rbp), %rax
jae 0x179d
movq -0xb8(%rbp), %rax
movzbl -0xaf(%rbp,%rax), %esi
leaq 0x2d05(%rip), %rdi      # 0x4487
movb $0x0, %al
callq 0x10b0
movq -0xb8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xb8(%rbp)
jmp 0x175c
leaq 0x28bd(%rip), %rdi      # 0x4061
movb $0x0, %al
callq 0x10b0
xorl %edi, %edi
callq 0x11f0
nopw %cs:(%rax,%rax)
nopl (%rax)