// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/src/tektag.c
// Function: tektagcode
void
tektagcode(void)
{
     int            floorz,hi,i,j,k,lo,oldang,p,r,s,tics;
     int           dax,dax2,day,day2,endwall,startwall;
     unsigned int  effect;
     sectortype     *sect;
     struct    sectoreffect   *septr;

     for( p=connecthead; p >= 0; p=connectpoint2[p] ) {
          tekanimweap((syncbits[p]>>13)&15,p);
          tekhealstun(p);
     }

     for( i=0; i < numdoors; i++ ) {
          movedoors(i);
     }

     if( option[4] == 0 ) {
          for( i=0; i < secnt; i++ ) {
               s=sexref[i];
              if (s < 0 || s >= numsectors) {
                   crashgame("tag1402: Invalid sector effect index (%d,e=%d)",s,i);
              }
               sect=sectptr[s];
               septr=septrlist[s];
               if( septr->triggerable != 0 ) {
                    continue;
               }
               effect=septr->sectorflags;
               if( (effect&flags32[WPANNING]) != 0 ) {
                    oldang=septr->ang;
                    tics=TICSPERFRAME;
                    startwall=sect->wallptr;
                    endwall=startwall+sect->wallnum-1;
                    dax=(tics*septr->cos)>>15;
                    day=(tics*septr->sin)>>13;
                    for( j=startwall; j <= endwall; j++ ) {
                         wallptr[j]->xpanning+=(unsigned char)dax;
                         wallptr[j]->ypanning-=(unsigned char)day;
                    }
               }
               if( (effect&flags32[FPANNING]) != 0 ) {
                    tics=TICSPERFRAME;
                    dax=(tics*septr->cos);
                    day=(tics*septr->sin);
                    j=headspritesect[s];
                    while( j != -1 ) {
                         k=nextspritesect[j];
                         if( sprptr[j]->owner < MAXSPRITES ) {
                              dax2=dax>>10;
                              day2=day>>10;
                              movesprite(j,dax2,day2,0,4<<8,4<<8,0);
                         }
                         j=k;
                    }
                    for( p=connecthead; p >= 0; p=connectpoint2[p] ) {
                         if( cursectnum[p] == s ) {
                              if( posz[p] >= (sect->floorz-(42<<8)) ) {
                                   clipmove(&posx[p],&posy[p],&posz[p],
                                            &cursectnum[p],dax<<4,day<<4,128L,4<<8,4<<8,CLIPMASK0);
                                   setsprite(playersprite[p],posx[p],posy[p],posz[p]+(42<<8));
                                   revolvedoorstat[p]=1;
                              }
                         }
                    }
                    dax>>=12;
                    day>>=12;
                    sect->floorxpanning-=(unsigned char)dax;
                    sect->floorypanning+=(unsigned char)day;
               }
               if( (effect&flags32[CPANNING]) != 0 ) {
                    tics=TICSPERFRAME;
                    dax=(tics*septr->cos)>>12;
                    day=(tics*septr->sin)>>12;
                    sect->ceilingxpanning-=(unsigned char)dax;
                    sect->ceilingypanning+=(unsigned char)day;
               }
               if( (septr->delay-=TICSPERFRAME) > 0 ) {
                    continue;
               }
               // negative overflow here without this - jeffy
               if( septr->delay < 0 ) {
                    septr->delay=0;
               }
               septr->delay+=septr->delayreset;
               if( (effect&flags32[PULSELIGHT]) != 0 ) {
                    sect->ceilingshade+=septr->animate;
                    if( septr->hi > septr->lo ) {
                         hi=septr->hi;
                         lo=septr->lo;
                    }
                    else {
                         hi=septr->lo;
                         lo=septr->hi;
                    }
                    if( septr->animate < 0 ) {
                         if( sect->ceilingshade <= lo ) {
                              septr->animate=abs(septr->animate);
                         }
                    }
                    else {
                         if( sect->ceilingshade >= hi ) {
                              septr->animate=-septr->animate;
                         }
                    }
                    sect->floorshade=sect->ceilingshade;
                    startwall=sect->wallptr;
                    endwall=startwall+sect->wallnum-1;
                    for( j=startwall; j <= endwall; j++ ) {
                         wallptr[j]->shade=sect->ceilingshade;
                    }
               }
               else if( (effect&flags32[FLICKERLIGHT]) != 0 ) {
                   r=krand_intercept("TAG 1491");
                    if( r < 16384 ) {
                         sect->ceilingshade=septr->hi;
                    }
                    else if( r > 16384 ) {
                         sect->ceilingshade=septr->lo;
                    }
                    sect->floorshade=sect->ceilingshade;
                    startwall=sect->wallptr;
                    endwall=startwall+sect->wallnum-1;
                    for( j=startwall; j <= endwall; j++ ) {
                         wallptr[j]->shade=sect->ceilingshade;
                    }
               }
               else if( (effect&flags32[FLICKERDELAY]) != 0 ) {
                    if( sect->ceilingshade == septr->lo ) {
                         sect->ceilingshade=septr->hi;
                    }
                    else {
                         sect->ceilingshade=septr->lo;
                         septr->delay>>=2;
                    }
                    sect->floorshade=sect->ceilingshade;
                    startwall=sect->wallptr;
                    endwall=startwall+sect->wallnum-1;
                    for( j=startwall; j <= endwall; j++ ) {
                         wallptr[j]->shade=sect->ceilingshade;
                    }
               }
               else if( (effect&flags32[BLINKDELAY]) != 0 ) {
                    if( sect->ceilingshade == septr->lo ) {
                         sect->ceilingshade=septr->hi;
                    }
                    else {
                         sect->ceilingshade=septr->lo;
                    }
                    sect->floorshade=sect->ceilingshade;
                    startwall=sect->wallptr;
                    endwall=startwall+sect->wallnum-1;
                    for( j=startwall; j <= endwall; j++ ) {
                         wallptr[j]->shade=sect->ceilingshade;
                    }
               }
               if( (effect&flags32[KILLSECTOR]) != 0 ) {
                    floorz=sectptr[s]->floorz;
                    for( p=connecthead ; p >= 0 ; p=connectpoint2[p] ) {
                         if( cursectnum[p] == s ) {
                              // matrix specific check here
                              if( (klabs(posz[p] - floorz) < 10240) || (mission == 7) ) {
                                   if( (k=fdxref[s]) != -1 ) {
                                        if( floordoorptr[k]->state != DOORCLOSED ) {
                                             changehealth(p,-septr->damage);
                                             changescore(p,-10);
                                        }
                                   }
                                   else {
                                        if( septr->delay == septr->delayreset ) {
                                             changehealth(p,-septr->damage);
                                             changescore(p,-10);
                                        }
                                   }
                              }
                         }
                    }
               }
          }
     }

     if( option[4] == 0 ) {
          for( i=0; i < sprelevcnt; i++ ) {
               movesprelevs(i);
          }
          for( i=0; i < numfloordoors; i++ ) {
               movefloordoor(i);
          }
          for( i=0; i < numvehicles; i++ ) {
               movevehicles(i);
          }
     }

     tekdoanimpic();
     tekdodelayfuncs();
     if( (lockclock-ambupdateclock) > 120 ) {
          checkmapsndfx(screenpeek);
     }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
leaq 0x77518d(%rip), %r14    # 0x79bb30
leaq 0xb3ae6(%rip), %r15     # 0xda490
movslq (%r14), %r14
testq %r14, %r14
js 0x269d9
movzwl (%r15,%r14,2), %edi
shrl $0xd, %edi
movswl %r14w, %ebx
movl %ebx, %esi
callq 0xf313
movl %ebx, %edi
callq 0x9b62
shlq $0x2, %r14
addq 0xa0609(%rip), %r14     # 0xc6fe0
jmp 0x269aa
xorl %ebx, %ebx
leaq 0x77515e(%rip), %r15    # 0x79bb40
cmpl 0x2f1a28(%rip), %ebx    # 0x318410
jge 0x269f5
movl %ebx, %edi
callq 0x2875c
incl %ebx
jmp 0x269e2
leaq 0xa0f7c(%rip), %rax     # 0xc7978
cmpb $0x0, 0x4(%rax)
jne 0x26f2d
leaq 0x28faf3(%rip), %r13    # 0x2b6500
leaq 0x1d081c(%rip), %rbx    # 0x1f7230
xorl %r14d, %r14d
movslq 0x28fad6(%rip), %rax    # 0x2b64f4
cmpq %rax, %r14
jge 0x26f20
movslq (%r13,%r14,4), %r12
testq %r12, %r12
js 0x26a40
leaq 0x5503a8(%rip), %rax    # 0x576de0
movswl (%rax), %eax
cmpl %eax, %r12d
jl 0x26a54
leaq 0x5c111(%rip), %rdi     # 0x82b58
movl %r12d, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x2acb8
movq %r14, 0x20(%rsp)
leaq 0x2cfaa0(%rip), %rax    # 0x2f6500
movq (%rax,%r12,8), %rax
movq %rax, (%rsp)
cmpl $0x0, 0x1c(%rax)
jne 0x26f13
leaq 0x1c87b7(%rip), %rax    # 0x1ef230
movq (%rax,%r12,8), %r14
movq (%rsp), %rax
movl (%rax), %eax
movl %eax, 0x8(%rsp)
testl %eax, 0xa1e6f(%rip)     # 0xc88fc
je 0x26ac6
movswq (%r14), %rax
movswq 0x2(%r14), %rcx
addq %rax, %rcx
movq (%rsp), %rsi
imull $0x3, 0x34(%rsi), %edx
shrl $0xf, %edx
imull $0x3, 0x30(%rsi), %esi
shrl $0xd, %esi
cmpq %rcx, %rax
jge 0x26ac6
movq (%rbx,%rax,8), %rdi
addb %dl, 0x18(%rdi)
movq (%rbx,%rax,8), %rdi
subb %sil, 0x19(%rdi)
incq %rax
jmp 0x26aad
movl 0x8(%rsp), %eax
testl %eax, 0xa1e30(%rip)     # 0xc8900
je 0x26c82
movq %r14, 0x18(%rsp)
movq (%rsp), %rax
movl 0x30(%rax), %r14d
movl 0x34(%rax), %r15d
leal (%r15,%r15,2), %ebx
leal (%r14,%r14,2), %r13d
leaq 0x52c89a(%rip), %rax    # 0x553390
movzwl (%rax,%r12,2), %ebp
movl %ebx, 0xc(%rsp)
sarl $0xa, %ebx
movl %r13d, 0x10(%rsp)
sarl $0xa, %r13d
cmpw $-0x1, %bp
je 0x26b5a
movl %ebp, %eax
movswq %bp, %rcx
leaq 0x536882(%rip), %rdx    # 0x55d3a0
movzwl (%rdx,%rcx,2), %ebp
leaq 0x100707(%rip), %rdx    # 0x127230
movq (%rdx,%rcx,8), %rcx
cmpw $0x3fff, 0x1e(%rcx)     # imm = 0x3FFF
jg 0x26b0b
subq $0x8, %rsp
movswl %ax, %edi
movl %ebx, %esi
movl %r13d, %edx
xorl %ecx, %ecx
movl $0x400, %r8d            # imm = 0x400
movl $0x400, %r9d            # imm = 0x400
pushq $0x0
callq 0x1b89a
popq %rcx
popq %rdx
jmp 0x26b0b
imull $0x30, %r15d, %eax
movl %eax, 0x14(%rsp)
imull $0x30, %r14d, %ebx
leaq 0x774fc3(%rip), %r13    # 0x79bb30
leaq 0x774fcc(%rip), %r15    # 0x79bb40
leaq 0xb4ba5(%rip), %rcx     # 0xdb720
movq 0x18(%rsp), %r14
movslq (%r13), %r13
testq %r13, %r13
js 0x26c5a
movswl (%rcx,%r13,2), %eax
cmpl %eax, %r12d
jne 0x26c4e
movl 0x8(%r14), %eax
movl $0xffffd600, %edx       # imm = 0xFFFFD600
addl %edx, %eax
leaq 0xb39a3(%rip), %rdx     # 0xda550
cmpl %eax, (%rdx,%r13,4)
jl 0x26c4e
leaq 0xb4b62(%rip), %rax     # 0xdb720
leaq (%rax,%r13,2), %rcx
leaq 0xb3987(%rip), %rax     # 0xda550
leaq (%rax,%r13,4), %r14
leaq 0xb38fc(%rip), %rax     # 0xda4d0
leaq (%rax,%r13,4), %rbp
leaq 0xb3931(%rip), %rax     # 0xda510
leaq (%rax,%r13,4), %r15
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
movl 0x14(%rsp), %r8d
movl %ebx, %r9d
pushq $0x10001                # imm = 0x10001
movl $0x400, %eax            # imm = 0x400
pushq %rax
pushq %rax
pushq $0x80
callq 0x460b8
addq $0x20, %rsp
leaq 0xb4b3b(%rip), %rax     # 0xdb750
movswl (%rax,%r13,2), %edi
movl (%rbp), %esi
movl (%r15), %edx
leaq 0x774f19(%rip), %r15    # 0x79bb40
movl (%r14), %ecx
movq 0x18(%rsp), %r14
movl $0x2a00, %eax           # imm = 0x2A00
addl %eax, %ecx
callq 0x43f76
leaq 0xb4ade(%rip), %rcx     # 0xdb720
leaq 0xb4af7(%rip), %rax     # 0xdb740
movb $0x1, (%rax,%r13)
shlq $0x2, %r13
addq %r15, %r13
jmp 0x26b80
movl 0xc(%rsp), %eax
shrl $0xc, %eax
subb %al, 0x1e(%r14)
movl 0x10(%rsp), %eax
shrl $0xc, %eax
addb %al, 0x1f(%r14)
leaq 0x28f889(%rip), %r13    # 0x2b6500
leaq 0x1d05b2(%rip), %rbx    # 0x1f7230
movl 0x8(%rsp), %eax
testl %eax, 0xa1c7c(%rip)     # 0xc8904
movq (%rsp), %rcx
je 0x26cac
imull $0x3, 0x34(%rcx), %eax
movq (%rsp), %rcx
imull $0x3, 0x30(%rcx), %ecx
shrl $0xc, %eax
subb %al, 0x16(%r14)
shrl $0xc, %ecx
addb %cl, 0x17(%r14)
movq (%rsp), %rcx
movl 0x10(%rcx), %eax
movq %rcx, %rdx
leal -0x3(%rax), %ecx
movl %ecx, 0x10(%rdx)
cmpl $0x3, %eax
jg 0x26f13
movq (%rsp), %rcx
movl 0x14(%rcx), %eax
movl %eax, 0x10(%rcx)
movl 0x8(%rsp), %eax
testl %eax, 0xa1c1b(%rip)     # 0xc88f0
je 0x26d2f
movb 0x14(%r14), %sil
addb 0x4(%rcx), %sil
movb %sil, 0x14(%r14)
movl 0x4(%rcx), %eax
movl 0x8(%rcx), %edx
movl 0xc(%rcx), %ecx
movsbl %sil, %esi
testl %eax, %eax
js 0x26d53
cmpl %ecx, %edx
cmovgl %edx, %ecx
cmpl %esi, %ecx
jg 0x26d06
negl %eax
movq (%rsp), %rcx
movl %eax, 0x4(%rcx)
movb 0x14(%r14), %al
movb %al, 0x1c(%r14)
movswq (%r14), %rcx
movswq 0x2(%r14), %rdx
addq %rcx, %rdx
cmpq %rdx, %rcx
jge 0x26e30
movq (%rbx,%rcx,8), %rsi
movb %al, 0x14(%rsi)
incq %rcx
jmp 0x26d1a
testl %eax, 0xa1bbf(%rip)     # 0xc88f4
je 0x26d5e
leaq 0x5be49(%rip), %rdi     # 0x82b87
callq 0x2945b
cmpl $0x3fff, %eax           # imm = 0x3FFF
jg 0x26d86
movq (%rsp), %rax
movb 0x8(%rax), %al
jmp 0x26d9a
cmpl %ecx, %edx
cmovll %edx, %ecx
cmpl %esi, %ecx
jge 0x26cfd
jmp 0x26d06
testl %eax, 0xa1ba4(%rip)     # 0xc8908
je 0x26dbf
movsbl 0x14(%r14), %ecx
movq (%rsp), %rdx
movl 0xc(%rdx), %eax
cmpl %ecx, %eax
jne 0x26e03
movb 0x8(%rdx), %al
movb %al, 0x14(%r14)
jmp 0x26e0f
cmpl $0x4000, %eax           # imm = 0x4000
movq (%rsp), %rax
jne 0x26d97
movb 0x14(%r14), %al
jmp 0x26d9e
movb 0xc(%rax), %al
movb %al, 0x14(%r14)
movb %al, 0x1c(%r14)
movswq (%r14), %rcx
movswq 0x2(%r14), %rdx
addq %rcx, %rdx
cmpq %rdx, %rcx
jge 0x26e30
movq (%rbx,%rcx,8), %rsi
movb %al, 0x14(%rsi)
incq %rcx
jmp 0x26dae
testl %eax, 0xa1b47(%rip)     # 0xc890c
je 0x26e30
movsbl 0x14(%r14), %ecx
movq (%rsp), %rax
movl 0xc(%rax), %eax
cmpl %ecx, %eax
jne 0x26dde
movq (%rsp), %rax
movl 0x8(%rax), %eax
movb %al, 0x14(%r14)
movb %al, 0x1c(%r14)
movswq (%r14), %rcx
movswq 0x2(%r14), %rdx
addq %rcx, %rdx
cmpq %rdx, %rcx
jge 0x26e30
movq (%rbx,%rcx,8), %rsi
movb %al, 0x14(%rsi)
incq %rcx
jmp 0x26df2
movb %al, 0x14(%r14)
sarl $0x2, 0x10(%rdx)
movb 0x14(%r14), %al
movb %al, 0x1c(%r14)
movswq (%r14), %rcx
movswq 0x2(%r14), %rdx
addq %rcx, %rdx
cmpq %rdx, %rcx
jge 0x26e30
movq (%rbx,%rcx,8), %rsi
movb %al, 0x14(%rsi)
incq %rcx
jmp 0x26e1f
movl 0x8(%rsp), %eax
testl %eax, 0xa1ade(%rip)     # 0xc8918
leaq 0xb48df(%rip), %rcx     # 0xdb720
je 0x26f13
leaq 0x1c83e2(%rip), %rax    # 0x1ef230
movq (%rax,%r12,8), %rax
movl 0x8(%rax), %ebp
leaq 0x774cd4(%rip), %r14    # 0x79bb30
movslq (%r14), %r14
testq %r14, %r14
js 0x26f13
movswl (%rcx,%r14,2), %eax
cmpl %eax, %r12d
jne 0x26ef9
leaq 0xb36d3(%rip), %rax     # 0xda550
movl (%rax,%r14,4), %eax
subl %ebp, %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
cmpl $0x2800, %ecx           # imm = 0x2800
leaq 0xb4889(%rip), %rcx     # 0xdb720
jb 0x26ea5
leaq 0xfe670(%rip), %rax     # 0x125510
cmpl $0x7, (%rax)
jne 0x26ef9
leaq 0x2e4ac4(%rip), %rax    # 0x30b970
movslq (%rax,%r12,4), %rax
cmpq $-0x1, %rax
je 0x26f05
leaq 0x2e8d73(%rip), %rdx    # 0x30fc30
movq (%rdx,%rax,8), %rax
cmpl $0x0, (%rax)
je 0x26ef9
movq (%rsp), %rax
movzwl 0x38(%rax), %eax
xorl %ecx, %ecx
subw %ax, %cx
movswl %cx, %esi
movswl %r14w, %ebx
movl %ebx, %edi
callq 0x99a8
movl %ebx, %edi
leaq 0x1d0346(%rip), %rbx    # 0x1f7230
pushq $-0xa
popq %rsi
callq 0x9adc
leaq 0xb4827(%rip), %rcx     # 0xdb720
shlq $0x2, %r14
addq %r15, %r14
jmp 0x26e5c
movq (%rsp), %rdx
movl 0x10(%rdx), %eax
cmpl 0x14(%rdx), %eax
je 0x26ec6
jmp 0x26ef9
movq 0x20(%rsp), %r14
incq %r14
jmp 0x26a17
leaq 0xa0a51(%rip), %rax     # 0xc7978
cmpb $0x0, 0x4(%rax)
je 0x26f77
callq 0x2a0a3
callq 0x2a170
leaq 0xb354a(%rip), %rax     # 0xda488
movl (%rax), %eax
subl 0x2fdbfa(%rip), %eax    # 0x324b40
cmpl $0x79, %eax
jl 0x26f68
leaq 0xb350c(%rip), %rax     # 0xda45e
movswl (%rax), %edi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x28514
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
cmpl 0x2fd4a1(%rip), %ebx    # 0x324420
jge 0x26f8c
movl %ebx, %edi
callq 0x294bb
incl %ebx
jmp 0x26f79
xorl %ebx, %ebx
cmpl 0x2e49cc(%rip), %ebx    # 0x30b960
jge 0x26fa1
movl %ebx, %edi
callq 0x29667
incl %ebx
jmp 0x26f8e
xorl %ebx, %ebx
cmpl 0x2eaf37(%rip), %ebx    # 0x311ee0
jge 0x26f2d
movl %ebx, %edi
callq 0x298df
incl %ebx
jmp 0x26fa3