// File: /workspace/github_c_makefile_star2_O1/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, 0xc01e5(%rip)     # 0xce97c
je 0xe92a
leaq 0x79436c(%rip), %rax    # 0x7a2b10
movl (%rax), %edx
movslq %edx, %rcx
leaq 0x794370(%rip), %rsi    # 0x7a2b20
leaq 0xd2cd9(%rip), %rdi     # 0xe1490
movl %edx, %r9d
movslq (%rsi,%rcx,4), %rcx
testq %rcx, %rcx
js 0xe92a
movl %r9d, %r8d
testb $0x2, 0x1(%rdi,%rcx,2)
movl %ecx, %r9d
je 0xe7ba
pushq %rbp
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 0x119497(%rip), %al     # 0x127c85
incb %al
movb %al, 0xd3d1a(%rip)      # 0xe2510
movb 0x11bc94(%rip), %al     # 0x12a490
incb %al
movb %al, 0xd3d0d(%rip)      # 0xe2511
movzwl 0x11947b(%rip), %eax    # 0x127c86
incl %eax
movw %ax, 0xd3cfe(%rip)      # 0xe2512
movzwl 0x11bc77(%rip), %eax    # 0x12a492
incl %eax
movw %ax, 0xd3cf0(%rip)      # 0xe2514
movzwl 0x11945d(%rip), %eax    # 0x127c88
incl %eax
movw %ax, 0xd3ce2(%rip)      # 0xe2516
movzwl 0x11bc59(%rip), %eax    # 0x12a494
incl %eax
movw %ax, 0xd3cd4(%rip)      # 0xe2518
movzwl 0xd4359(%rip), %eax     # 0xe2ba4
incl %eax
movw %ax, 0xd3cc6(%rip)      # 0xe251a
movzwl 0x11bc3b(%rip), %eax    # 0x12a496
incl %eax
movw %ax, 0xd3cb8(%rip)      # 0xe251c
xorl %eax, %eax
leaq 0xd3ce3(%rip), %rcx     # 0xe2550
leaq 0xd3cbc(%rip), %rdx     # 0xe2530
leaq 0xd3d25(%rip), %rsi     # 0xe25a0
leaq 0xd3cde(%rip), %rdi     # 0xe2560
leaq 0xd3d77(%rip), %r8      # 0xe2600
leaq 0xd3d30(%rip), %r9      # 0xe25c0
leaq 0xd3da9(%rip), %r10     # 0xe2640
leaq 0xd3d82(%rip), %r11     # 0xe2620
xorl %ebx, %ebx
movb (%rbx,%rcx), %bpl
incb %bpl
movb %bpl, (%rbx,%rdx)
movzwl (%rax,%rsi), %ebp
incl %ebp
movw %bp, (%rax,%rdi)
movzwl (%rax,%r8), %ebp
incl %ebp
movw %bp, (%rax,%r9)
movzwl (%rax,%r10), %ebp
incl %ebp
movw %bp, (%rax,%r11)
incq %rbx
addq $0x2, %rax
cmpq $0x10, %rbx
jne 0xe8a0
xorl %eax, %eax
movl %eax, 0xd3c16(%rip)     # 0xe24f8
movl %eax, 0xd3c14(%rip)     # 0xe24fc
movl %eax, 0xd3c12(%rip)     # 0xe2500
movl %eax, 0xd3c10(%rip)     # 0xe2504
movl %eax, 0xd3c0e(%rip)     # 0xe2508
movl %eax, 0xd3c0c(%rip)     # 0xe250c
movl 0xd2b82(%rip), %eax     # 0xe1488
leaq 0x54ba3b(%rip), %rcx    # 0x55a348
movl %eax, (%rcx)
movl %eax, 0xd2b3f(%rip)     # 0xe1454
movl %eax, 0xd2b3d(%rip)     # 0xe1458
movl %eax, 0xd3bff(%rip)     # 0xe2520
movb $0x1, 0xd2b2b(%rip)     # 0xe1453
popq %rbx
popq %rbp
retq