// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/src/tekgame.c
// Function: checkmasterslaveswitch
void
checkmasterslaveswitch()
{
     int i, j;

     if (option[4] == 0) return;

     i = connecthead; j = connectpoint2[i];
     while (j >= 0)
     {
          if ((syncbits[j]&512) > 0)
          {
               connectpoint2[i] = connectpoint2[j];
               connectpoint2[j] = connecthead;
               connecthead = (short)j;

               olocvel = locvel+1; olocvel2 = locvel2+1;
               olocsvel = locsvel+1; olocsvel2 = locsvel2+1;
               olocangvel = locangvel+1; olocangvel2 = locangvel2+1;
               olocbits = locbits+1; olocbits2 = locbits2+1;
               for(i=0;i<MAXPLAYERS;i++)
               {
                    osyncvel[i] = fsyncvel[i]+1;
                    osyncsvel[i] = fsyncsvel[i]+1;
                    osyncangvel[i] = fsyncangvel[i]+1;
                    osyncbits[i] = fsyncbits[i]+1;
               }

               syncvalplc = 0L; othersyncvalplc = 0L;
               syncvalend = 0L; othersyncvalend = 0L;
               syncvalcnt = 0L; othersyncvalcnt = 0L;

               totalclock = lockclock;
               ototalclock = lockclock;
               gotlastpacketclock = lockclock;
               masterslavetexttime = lockclock;
               ready2send = 1;
               return;
          }
          i = j; j = connectpoint2[i];
     }
}

// Assembly:
cmpb $0x0, 0xc31ed(%rip)     # 0xd197c
je 0xe934
leaq 0x797394(%rip), %rax    # 0x7a5b30
movl (%rax), %edx
movslq %edx, %rcx
leaq 0x797398(%rip), %rsi    # 0x7a5b40
leaq 0xd5ce1(%rip), %rdi     # 0xe4490
movl %edx, %r9d
movslq (%rsi,%rcx,4), %rcx
testq %rcx, %rcx
js 0xe934
movl %r9d, %r8d
testb $0x2, 0x1(%rdi,%rcx,2)
movl %ecx, %r9d
je 0xe7b2
pushq %rbx
movl (%rsi,%rcx,4), %edi
movslq %r8d, %r8
movl %edi, (%rsi,%r8,4)
movl %edx, (%rsi,%rcx,4)
movswl %cx, %ecx
movl %ecx, (%rax)
movb 0x11c4a0(%rip), %al     # 0x12ac85
incb %al
movb %al, 0xd6d23(%rip)      # 0xe5510
movb 0x11ec9d(%rip), %al     # 0x12d490
incb %al
movb %al, 0xd6d16(%rip)      # 0xe5511
movzwl 0x11c484(%rip), %eax    # 0x12ac86
incl %eax
movw %ax, 0xd6d07(%rip)      # 0xe5512
movzwl 0x11ec80(%rip), %eax    # 0x12d492
incl %eax
movw %ax, 0xd6cf9(%rip)      # 0xe5514
movzwl 0x11c466(%rip), %eax    # 0x12ac88
incl %eax
movw %ax, 0xd6ceb(%rip)      # 0xe5516
movzwl 0x11ec62(%rip), %eax    # 0x12d494
incl %eax
movw %ax, 0xd6cdd(%rip)      # 0xe5518
movzwl 0xd7362(%rip), %eax     # 0xe5ba4
incl %eax
movw %ax, 0xd6ccf(%rip)      # 0xe551a
movzwl 0x11ec44(%rip), %eax    # 0x12d496
incl %eax
movw %ax, 0xd6cc1(%rip)      # 0xe551c
xorl %eax, %eax
leaq 0xd6cec(%rip), %rcx     # 0xe5550
pcmpeqd %xmm0, %xmm0
leaq 0xd6cc1(%rip), %rdx     # 0xe5530
leaq 0xd6d2a(%rip), %rsi     # 0xe55a0
leaq 0xd6ce3(%rip), %rdi     # 0xe5560
leaq 0xd6d7c(%rip), %r8      # 0xe5600
leaq 0xd6d35(%rip), %r9      # 0xe55c0
leaq 0xd6dae(%rip), %r10     # 0xe5640
leaq 0xd6d87(%rip), %r11     # 0xe5620
xorl %ebx, %ebx
movq (%rbx,%rcx), %xmm1
psubb %xmm0, %xmm1
movq %xmm1, (%rbx,%rdx)
movdqa (%rax,%rsi), %xmm1
psubw %xmm0, %xmm1
movdqa %xmm1, (%rax,%rdi)
movdqa (%rax,%r8), %xmm1
psubw %xmm0, %xmm1
movdqa %xmm1, (%rax,%r9)
movdqa (%rax,%r10), %xmm1
psubw %xmm0, %xmm1
movdqa %xmm1, (%rax,%r11)
addq $0x8, %rbx
addq $0x10, %rax
cmpq $0x10, %rbx
jne 0xe89b
xorl %eax, %eax
movl %eax, 0xd6c0b(%rip)     # 0xe54f8
movl %eax, 0xd6c09(%rip)     # 0xe54fc
movl %eax, 0xd6c07(%rip)     # 0xe5500
movl %eax, 0xd6c05(%rip)     # 0xe5504
movl %eax, 0xd6c03(%rip)     # 0xe5508
movl %eax, 0xd6c01(%rip)     # 0xe550c
movl 0xd5b77(%rip), %eax     # 0xe4488
leaq 0x54ea50(%rip), %rcx    # 0x55d368
movl %eax, (%rcx)
movl %eax, 0xd5b34(%rip)     # 0xe4454
movl %eax, 0xd5b32(%rip)     # 0xe4458
movl %eax, 0xd6bf4(%rip)     # 0xe5520
movb $0x1, 0xd5b20(%rip)     # 0xe4453
popq %rbx
retq