// File: /workspace/github_c_makefile_star2_O0/pavel-demin[P]ft8d-c/ft8d.c
// Function: unpack
int unpack(char *call, char *grid)
{
  int i, n;
  uint64_t icall;
  uint16_t igrid;
  uint8_t i3, iflip;

  call[0] = 0;
  grid[0] = 0;

  i3 = 0;
  for(i = 0; i < 3; ++i) i3 |= message[76 - i] << i;

  if(i3 == 1 || i3 == 2)
  {
    icall = 0;
    for(i = 0; i < 28; ++i) icall |= message[56 - i] << i;

    igrid = 0;
    for(i = 0; i < 15; ++i) igrid |= message[73 - i] << i;

    if(igrid <= MAXGRID && igrid != 32373)
    {
      grid[4] = 0;
      n = igrid;
      grid[3] = '0' + (n % 10);
      n /= 10;
      grid[2] = '0' + (n % 10);
      n /= 10;
      grid[1] = 'A' + (n % 18);
      n /= 18;
      grid[0] = 'A' + (n % 18);
    }

    n = icall - NTOKENS - MAX22;

    if(n < 0) return 0;

    call[6] = 0;
    for(i = 0; i < 3; ++i)
    {
      call[5 - i] = c4[n % 27];
      n /= 27;
    }
    call[2] = c3[n % 10];
    n /= 10;
    call[1] = c2[n % 36];
    n /= 36;
    call[0] = c1[n % 37];
    trim(call);

    return 1;
  }

  if(i3 == 4)
  {
    iflip = message[70];

    if(iflip) return 0;

    icall = 0;
    for(i = 0; i < 58; ++i) icall |= (uint64_t)message[69 - i] << i;
    call[11] = 0;
    for(i = 0; i < 11; ++i)
    {
      call[10 - i] = c0[icall % 38];
      icall /= 38;
    }
    trim(call);

    return 1;
  }

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movb $0x0, (%rax)
movq -0x18(%rbp), %rax
movb $0x0, (%rax)
movb $0x0, -0x2b(%rbp)
movl $0x0, -0x1c(%rbp)
cmpl $0x3, -0x1c(%rbp)
jge 0x172b0
movl $0x4c, %eax
subl -0x1c(%rbp), %eax
movslq %eax, %rcx
leaq 0x622f(%rip), %rax      # 0x1d4c0
movzbl (%rax,%rcx), %eax
movl -0x1c(%rbp), %ecx
shll %cl, %eax
movl %eax, %ecx
movzbl -0x2b(%rbp), %eax
orl %ecx, %eax
movb %al, -0x2b(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x17279
movzbl -0x2b(%rbp), %eax
cmpl $0x1, %eax
je 0x172c6
movzbl -0x2b(%rbp), %eax
cmpl $0x2, %eax
jne 0x1750c
movq $0x0, -0x28(%rbp)
movl $0x0, -0x1c(%rbp)
cmpl $0x1c, -0x1c(%rbp)
jge 0x1730b
movl $0x38, %eax
subl -0x1c(%rbp), %eax
movslq %eax, %rcx
leaq 0x61d3(%rip), %rax      # 0x1d4c0
movzbl (%rax,%rcx), %eax
movl -0x1c(%rbp), %ecx
shll %cl, %eax
cltq
orq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x172d5
movw $0x0, -0x2a(%rbp)
movl $0x0, -0x1c(%rbp)
cmpl $0xf, -0x1c(%rbp)
jge 0x17350
movl $0x49, %eax
subl -0x1c(%rbp), %eax
movslq %eax, %rcx
leaq 0x6190(%rip), %rax      # 0x1d4c0
movzbl (%rax,%rcx), %eax
movl -0x1c(%rbp), %ecx
shll %cl, %eax
movl %eax, %ecx
movzwl -0x2a(%rbp), %eax
orl %ecx, %eax
movw %ax, -0x2a(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x17318
movzwl -0x2a(%rbp), %eax
cmpl $0x7e90, %eax           # imm = 0x7E90
jg 0x17402
movzwl -0x2a(%rbp), %eax
cmpl $0x7e75, %eax           # imm = 0x7E75
je 0x17402
movq -0x18(%rbp), %rax
movb $0x0, 0x4(%rax)
movzwl -0x2a(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
addl $0x30, %edx
movb %dl, %cl
movq -0x18(%rbp), %rax
movb %cl, 0x3(%rax)
movl -0x20(%rbp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
addl $0x30, %edx
movb %dl, %cl
movq -0x18(%rbp), %rax
movb %cl, 0x2(%rax)
movl -0x20(%rbp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl $0x12, %ecx
cltd
idivl %ecx
addl $0x41, %edx
movb %dl, %cl
movq -0x18(%rbp), %rax
movb %cl, 0x1(%rax)
movl -0x20(%rbp), %eax
movl $0x12, %ecx
cltd
idivl %ecx
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl $0x12, %ecx
cltd
idivl %ecx
addl $0x41, %edx
movb %dl, %cl
movq -0x18(%rbp), %rax
movb %cl, (%rax)
movq -0x28(%rbp), %rax
subq $0x1f7ce8, %rax         # imm = 0x1F7CE8
subq $0x400000, %rax         # imm = 0x400000
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x17427
movl $0x0, -0x4(%rbp)
jmp 0x175ed
movq -0x10(%rbp), %rax
movb $0x0, 0x6(%rax)
movl $0x0, -0x1c(%rbp)
cmpl $0x3, -0x1c(%rbp)
jge 0x1747f
movl -0x20(%rbp), %eax
movl $0x1b, %ecx
cltd
idivl %ecx
movslq %edx, %rcx
leaq 0x444f(%rip), %rax      # 0x1b8a0
movb (%rax,%rcx), %dl
movq -0x10(%rbp), %rax
movl $0x5, %ecx
subl -0x1c(%rbp), %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x20(%rbp), %eax
movl $0x1b, %ecx
cltd
idivl %ecx
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x17436
movl -0x20(%rbp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
movslq %edx, %rcx
leaq 0x4400(%rip), %rax      # 0x1b894
movb (%rax,%rcx), %cl
movq -0x10(%rbp), %rax
movb %cl, 0x2(%rax)
movl -0x20(%rbp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl $0x24, %ecx
cltd
idivl %ecx
movslq %edx, %rcx
leaq 0x43af(%rip), %rax      # 0x1b870
movb (%rax,%rcx), %cl
movq -0x10(%rbp), %rax
movb %cl, 0x1(%rax)
movl -0x20(%rbp), %eax
movl $0x24, %ecx
cltd
idivl %ecx
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl $0x25, %ecx
cltd
idivl %ecx
movslq %edx, %rcx
leaq 0x4352(%rip), %rax      # 0x1b840
movb (%rax,%rcx), %cl
movq -0x10(%rbp), %rax
movb %cl, (%rax)
movq -0x10(%rbp), %rdi
callq 0x17170
movl $0x1, -0x4(%rbp)
jmp 0x175ed
movzbl -0x2b(%rbp), %eax
cmpl $0x4, %eax
jne 0x175e6
movb 0x5fe7(%rip), %al       # 0x1d506
movb %al, -0x2c(%rbp)
cmpb $0x0, -0x2c(%rbp)
je 0x17534
movl $0x0, -0x4(%rbp)
jmp 0x175ed
movq $0x0, -0x28(%rbp)
movl $0x0, -0x1c(%rbp)
cmpl $0x3a, -0x1c(%rbp)
jge 0x17578
movl $0x45, %eax
subl -0x1c(%rbp), %eax
movslq %eax, %rcx
leaq 0x5f65(%rip), %rax      # 0x1d4c0
movzbl (%rax,%rcx), %eax
movl -0x1c(%rbp), %ecx
shlq %cl, %rax
orq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x17543
movq -0x10(%rbp), %rax
movb $0x0, 0xb(%rax)
movl $0x0, -0x1c(%rbp)
cmpl $0xb, -0x1c(%rbp)
jge 0x175d4
movq -0x28(%rbp), %rax
movl $0x26, %ecx
xorl %edx, %edx
divq %rcx
leaq 0x426e(%rip), %rax      # 0x1b810
movb (%rax,%rdx), %dl
movq -0x10(%rbp), %rax
movl $0xa, %ecx
subl -0x1c(%rbp), %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x28(%rbp), %rax
movl $0x26, %ecx
xorl %edx, %edx
divq %rcx
movq %rax, -0x28(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x17587
movq -0x10(%rbp), %rdi
callq 0x17170
movl $0x1, -0x4(%rbp)
jmp 0x175ed
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)