// File: /workspace/github_c_makefile_star2_O0/pavel-demin[P]ft8d-c/ft8d.c
// Function: sync
void sync()
{
  int i, j, k, m, n, jmax;
  real_t c, sum, r, rmax, s, smax;

  for(i = 0; i < NSYM; ++i)
  {
    memset(buffer, 0, sizeof(complex_t) * NFFT);

    for(j = 0; j < NSPS; ++j)
    {
      buffer[j] = window[j] * signal[i * NSTP + j];
    }

    pffft_transform_ordered(setup, buffer, buffer, NULL, PFFFT_FORWARD);

    for(j = 0; j < NFFT; ++j)
    {
      k = j < NFFT / 2 ? j + NFFT / 2 : j - NFFT / 2;
      map[i * NFFT + k] = cabsf(buffer[j]);
    }
  }

  for(i = 0; i < NFFT; ++i)
  {
    jmax = 0;
    rmax = 0;
    smax = 0;
    for(j = -10 * NSSY; j < 25 * NSSY; ++j)
    {
      r = 0;
      s = 0;
      for(k = 0; k < 7; ++k)
      {
        m = j + (k + 36) * NSSY;
        sum = 0;
        for(n = 0; n < 8; ++n) sum += map[m * NFFT + i + n * NFOS];
        c = map[m * NFFT + i + costas[k] * NFOS];
        r += 7 * c / (sum - c);
        s += 8 * c / sum;
      }
      r /= 7;
      s /= 7;
      if(smax < s)
      {
        jmax = j;
        rmax = r;
        smax = s;
      }
    }
    list[i].i = i;
    list[i].j = jmax;
    list[i].k = 1;
    list[i].r = rmax;
    list[i].s = smax;
  }

  for(i = 2; i < NFFT - 2; ++i)
  {
    if((list[i - 2].s > list[i].s && list[i - 1].s > list[i].s) || (list[i + 1].s > list[i].s && list[i + 2].s > list[i].s))
    {
      list[i].k = 0;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x0, -0x4(%rbp)
cmpl $0x3a9, -0x4(%rbp)      # imm = 0x3A9
jge 0x162cf
movq 0x572d(%rip), %rdi      # 0x1b8d0
xorl %esi, %esi
movl $0x6400, %edx           # imm = 0x6400
callq 0x10a0
movl $0x0, -0x8(%rbp)
cmpl $0x640, -0x8(%rbp)      # imm = 0x640
jge 0x16219
movslq -0x8(%rbp), %rcx
leaq 0x5716(%rip), %rax      # 0x1b8e0
movss (%rax,%rcx,4), %xmm0
movq 0x700a(%rip), %rax      # 0x1d1e0
movl -0x4(%rbp), %ecx
shll $0x6, %ecx
addl -0x8(%rbp), %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,8), %xmm3
movss 0x4(%rax,%rcx,8), %xmm2
movaps %xmm0, %xmm1
mulss %xmm3, %xmm1
mulss %xmm2, %xmm0
movq 0x56d1(%rip), %rax      # 0x1b8d0
movslq -0x8(%rbp), %rcx
movss %xmm1, (%rax,%rcx,8)
movss %xmm0, 0x4(%rax,%rcx,8)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x161b6
movq 0x6fc8(%rip), %rdi      # 0x1d1e8
movq 0x56a9(%rip), %rsi      # 0x1b8d0
movq 0x56a2(%rip), %rdx      # 0x1b8d0
xorl %eax, %eax
movl %eax, %ecx
xorl %r8d, %r8d
callq 0xd890
movl $0x0, -0x8(%rbp)
cmpl $0xc80, -0x8(%rbp)      # imm = 0xC80
jge 0x162bf
cmpl $0x640, -0x8(%rbp)      # imm = 0x640
jge 0x16260
movl -0x8(%rbp), %eax
addl $0x640, %eax            # imm = 0x640
movl %eax, -0x3c(%rbp)
jmp 0x1626b
movl -0x8(%rbp), %eax
subl $0x640, %eax            # imm = 0x640
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0xc(%rbp)
movq 0x5658(%rip), %rax      # 0x1b8d0
movslq -0x8(%rbp), %rcx
movss (%rax,%rcx,8), %xmm1
movss 0x4(%rax,%rcx,8), %xmm0
movss %xmm1, -0x38(%rbp)
movss %xmm0, -0x34(%rbp)
movsd -0x38(%rbp), %xmm0
callq 0x1070
movq 0x6f4e(%rip), %rax      # 0x1d1f0
imull $0xc80, -0x4(%rbp), %ecx # imm = 0xC80
addl -0xc(%rbp), %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x16241
jmp 0x162c1
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x1618f
movl $0x0, -0x4(%rbp)
cmpl $0xc80, -0x4(%rbp)      # imm = 0xC80
jge 0x164fa
movl $0x0, -0x18(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x28(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x30(%rbp)
movl $0xffffff9c, -0x8(%rbp) # imm = 0xFFFFFF9C
cmpl $0xfa, -0x8(%rbp)
jge 0x1646c
xorps %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x2c(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0x7, -0xc(%rbp)
jge 0x16407
movl -0x8(%rbp), %eax
movl -0xc(%rbp), %ecx
addl $0x24, %ecx
imull $0xa, %ecx, %ecx
addl %ecx, %eax
movl %eax, -0x10(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x20(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x8, -0x14(%rbp)
jge 0x16389
movq 0x6e94(%rip), %rax      # 0x1d1f0
imull $0xc80, -0x10(%rbp), %ecx # imm = 0xC80
addl -0x4(%rbp), %ecx
imull $0x5, -0x14(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
addss -0x20(%rbp), %xmm0
movss %xmm0, -0x20(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1634f
movq 0x6e60(%rip), %rax      # 0x1d1f0
imull $0xc80, -0x10(%rbp), %ecx # imm = 0xC80
addl -0x4(%rbp), %ecx
movslq -0xc(%rbp), %rsi
leaq 0x542b(%rip), %rdx      # 0x1b7d0
imull $0x5, (%rdx,%rsi,4), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x1c(%rbp)
movss 0x1c88(%rip), %xmm0     # 0x18048
mulss -0x1c(%rbp), %xmm0
movss -0x20(%rbp), %xmm1
subss -0x1c(%rbp), %xmm1
divss %xmm1, %xmm0
addss -0x24(%rbp), %xmm0
movss %xmm0, -0x24(%rbp)
movss 0x1c4f(%rip), %xmm0     # 0x18034
mulss -0x1c(%rbp), %xmm0
divss -0x20(%rbp), %xmm0
addss -0x2c(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x16325
movss -0x24(%rbp), %xmm0
movss 0x1c34(%rip), %xmm1     # 0x18048
divss %xmm1, %xmm0
movss %xmm0, -0x24(%rbp)
movss -0x2c(%rbp), %xmm0
movss 0x1c1e(%rip), %xmm1     # 0x18048
divss %xmm1, %xmm0
movss %xmm0, -0x2c(%rbp)
movss -0x30(%rbp), %xmm1
movss -0x2c(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x1645c
movl -0x8(%rbp), %eax
movl %eax, -0x18(%rbp)
movss -0x24(%rbp), %xmm0
movss %xmm0, -0x28(%rbp)
movss -0x2c(%rbp), %xmm0
movss %xmm0, -0x30(%rbp)
jmp 0x1645e
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x16301
movl -0x4(%rbp), %ecx
movq 0x6d82(%rip), %rax      # 0x1d1f8
movslq -0x4(%rbp), %rdx
imulq $0x14, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x18(%rbp), %ecx
movq 0x6d6b(%rip), %rax      # 0x1d1f8
movslq -0x4(%rbp), %rdx
imulq $0x14, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movq 0x6d56(%rip), %rax      # 0x1d1f8
movslq -0x4(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movl $0x1, 0x8(%rax)
movss -0x28(%rbp), %xmm0
movq 0x6d38(%rip), %rax      # 0x1d1f8
movslq -0x4(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0xc(%rax)
movss -0x30(%rbp), %xmm0
movq 0x6d1c(%rip), %rax      # 0x1d1f8
movslq -0x4(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x10(%rax)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x162d6
movl $0x2, -0x4(%rbp)
cmpl $0xc7e, -0x4(%rbp)      # imm = 0xC7E
jge 0x16607
movq 0x6ce3(%rip), %rax      # 0x1d1f8
movl -0x4(%rbp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movss 0x10(%rax), %xmm0
movq 0x6cc7(%rip), %rax      # 0x1d1f8
movslq -0x4(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
ucomiss 0x10(%rax), %xmm0
jbe 0x16576
movq 0x6caf(%rip), %rax      # 0x1d1f8
movl -0x4(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movss 0x10(%rax), %xmm0
movq 0x6c93(%rip), %rax      # 0x1d1f8
movslq -0x4(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
ucomiss 0x10(%rax), %xmm0
ja 0x165de
movq 0x6c7b(%rip), %rax      # 0x1d1f8
movl -0x4(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movss 0x10(%rax), %xmm0
movq 0x6c5f(%rip), %rax      # 0x1d1f8
movslq -0x4(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
ucomiss 0x10(%rax), %xmm0
jbe 0x165f7
movq 0x6c47(%rip), %rax      # 0x1d1f8
movl -0x4(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movss 0x10(%rax), %xmm0
movq 0x6c2b(%rip), %rax      # 0x1d1f8
movslq -0x4(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
ucomiss 0x10(%rax), %xmm0
jbe 0x165f7
movq 0x6c13(%rip), %rax      # 0x1d1f8
movslq -0x4(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x8(%rax)
jmp 0x165f9
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x16501
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)