// File: /workspace/github_c_makefile_star2_O1/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 0x779c91(%rip), %rax    # 0x7a2b10
movl (%rax), %eax
testl %eax, %eax
js 0x28eb7
leaq 0xb8604(%rip), %r14     # 0xe1490
leaq 0x779c8d(%rip), %r15    # 0x7a2b20
movl %eax, %r12d
movzwl (%r14,%r12,2), %edi
shrl $0xd, %edi
movswl %ax, %ebx
movl %ebx, %esi
callq 0x10312
movl %ebx, %edi
callq 0xa795
movl (%r15,%r12,4), %eax
testl %eax, %eax
jns 0x28e93
cmpl $0x0, 0x2f6532(%rip)    # 0x31f3f0
jle 0x28ed3
xorl %ebx, %ebx
movl %ebx, %edi
callq 0x2ad30
incl %ebx
cmpl 0x2f651f(%rip), %ebx    # 0x31f3f0
jl 0x28ec2
leaq 0xa5a9e(%rip), %rax     # 0xce978
cmpb $0x0, 0x4(%rax)
jne 0x29423
cmpl $0x0, 0x2945e9(%rip)    # 0x2bd4d4
jle 0x29423
leaq 0x2945e8(%rip), %r13    # 0x2bd4e0
xorl %ebx, %ebx
movslq (%r13,%rbx,4), %r12
testq %r12, %r12
js 0x28f13
leaq 0x554eb5(%rip), %rax    # 0x57ddc0
movswl (%rax), %eax
cmpl %eax, %r12d
jl 0x28f26
leaq 0x64bbe(%rip), %rdi     # 0x8dad8
movl %r12d, %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x2d800
movq %rbx, 0x20(%rsp)
leaq 0x2d45ae(%rip), %rax    # 0x2fd4e0
movq (%rax,%r12,8), %rcx
cmpl $0x0, 0x1c(%rcx)
jne 0x2940b
leaq 0x1cd2c9(%rip), %rax    # 0x1f6210
movq (%rax,%r12,8), %r15
movq %rcx, (%rsp)
movl (%rcx), %ebp
testl %ebp, 0xa69a5(%rip)     # 0xcf8fc
leaq 0x1d52b2(%rip), %r8     # 0x1fe210
je 0x28f9e
movswq 0x2(%r15), %rax
testq %rax, %rax
jle 0x28f9e
movswq (%r15), %rcx
addq %rcx, %rax
movq (%rsp), %rsi
movl 0x30(%rsi), %edx
movl 0x34(%rsi), %esi
leal (%rdx,%rdx,2), %edx
shrl $0xd, %edx
leal (%rsi,%rsi,2), %esi
shrl $0xf, %esi
movq (%r8,%rcx,8), %rdi
addb %sil, 0x18(%rdi)
movq (%r8,%rcx,8), %rdi
subb %dl, 0x19(%rdi)
incq %rcx
cmpq %rax, %rcx
jl 0x28f87
testl %ebp, 0xa695c(%rip)     # 0xcf900
movq (%rsp), %rdx
je 0x2915b
movl %ebp, 0x18(%rsp)
movl 0x30(%rdx), %ecx
movl 0x34(%rdx), %r14d
leal (%r14,%r14,2), %eax
movl %eax, 0x8(%rsp)
movq %rcx, 0x10(%rsp)
leal (%rcx,%rcx,2), %eax
movl %eax, 0xc(%rsp)
leaq 0x53139c(%rip), %rax    # 0x55a370
movzwl (%rax,%r12,2), %eax
cmpw $-0x1, %ax
je 0x2903e
movl 0x8(%rsp), %ebp
sarl $0xa, %ebp
movl 0xc(%rsp), %r13d
sarl $0xa, %r13d
movswq %ax, %rcx
leaq 0x53b386(%rip), %rdx    # 0x564380
movzwl (%rdx,%rcx,2), %ebx
leaq 0x10520b(%rip), %rdx    # 0x12e210
movq (%rdx,%rcx,8), %rcx
cmpw $0x3fff, 0x1e(%rcx)     # imm = 0x3FFF
jg 0x29036
subq $0x8, %rsp
movswl %ax, %edi
movl %ebp, %esi
movl %r13d, %edx
xorl %ecx, %ecx
movl $0x400, %r8d            # imm = 0x400
movl $0x400, %r9d            # imm = 0x400
pushq $0x0
callq 0x1cfc1
addq $0x10, %rsp
movl %ebx, %eax
cmpw $-0x1, %bx
jne 0x28fef
leaq 0x779acb(%rip), %rax    # 0x7a2b10
movl (%rax), %eax
testl %eax, %eax
leaq 0xb96d0(%rip), %rbx     # 0xe2720
js 0x29136
shll $0x4, %r14d
leal (%r14,%r14,2), %ecx
movl %ecx, 0x1c(%rsp)
movq 0x10(%rsp), %rcx
shll $0x4, %ecx
leal (%rcx,%rcx,2), %ecx
movl %ecx, 0x10(%rsp)
movl %eax, %r13d
movswl (%rbx,%r13,2), %eax
cmpl %eax, %r12d
jne 0x29123
movl 0x8(%r15), %eax
movl $0xffffd600, %ecx       # imm = 0xFFFFD600
addl %ecx, %eax
leaq 0xb84bc(%rip), %rcx     # 0xe1550
cmpl %eax, (%rcx,%r13,4)
jl 0x29123
leaq (%rbx,%r13,2), %rcx
leaq 0xb84a7(%rip), %rax     # 0xe1550
leaq (%rax,%r13,4), %rbx
leaq 0xb841c(%rip), %rax     # 0xe14d0
leaq (%rax,%r13,4), %r14
leaq 0xb8451(%rip), %rax     # 0xe1510
leaq (%rax,%r13,4), %rbp
movq %r14, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movl 0x1c(%rsp), %r8d
movl 0x10(%rsp), %r9d
pushq $0x10001                # imm = 0x10001
movl $0x400, %eax            # imm = 0x400
pushq %rax
pushq %rax
pushq $0x80
callq 0x48f87
addq $0x20, %rsp
leaq 0xb9659(%rip), %rax     # 0xe2750
movswl (%rax,%r13,2), %edi
movl (%r14), %esi
movl (%rbp), %edx
movl (%rbx), %ecx
leaq 0xb9615(%rip), %rbx     # 0xe2720
movl $0x2a00, %eax           # imm = 0x2A00
addl %eax, %ecx
callq 0x46b48
leaq 0xb9622(%rip), %rax     # 0xe2740
movb $0x1, (%rax,%r13)
leaq 0x7799f6(%rip), %rax    # 0x7a2b20
movl (%rax,%r13,4), %eax
testl %eax, %eax
jns 0x29071
movl 0x8(%rsp), %eax
shrl $0xc, %eax
subb %al, 0x1e(%r15)
movl 0xc(%rsp), %eax
shrl $0xc, %eax
addb %al, 0x1f(%r15)
leaq 0x29438d(%rip), %r13    # 0x2bd4e0
movq (%rsp), %rdx
movl 0x18(%rsp), %ebp
testl %ebp, 0xa67a3(%rip)     # 0xcf904
je 0x2917d
movl 0x30(%rdx), %eax
movl 0x34(%rdx), %ecx
leal (%rcx,%rcx,2), %ecx
shrl $0xc, %ecx
leal (%rax,%rax,2), %eax
subb %cl, 0x16(%r15)
shrl $0xc, %eax
addb %al, 0x17(%r15)
movl 0x10(%rdx), %eax
leal -0x3(%rax), %ecx
movl %ecx, 0x10(%rdx)
cmpl $0x3, %eax
jg 0x2940b
je 0x29198
movl $0x0, 0x10(%rdx)
movl 0x14(%rdx), %eax
addl %eax, 0x10(%rdx)
testl %ebp, 0xa674c(%rip)     # 0xcf8f0
je 0x29218
movb 0x14(%r15), %sil
addb 0x4(%rdx), %sil
movb %sil, 0x14(%r15)
movl 0x4(%rdx), %eax
movq %rdx, %rcx
movl 0x8(%rdx), %edx
movl 0xc(%rcx), %ecx
movsbl %sil, %esi
testl %eax, %eax
leaq 0x1d5045(%rip), %rdi    # 0x1fe210
js 0x29286
cmpl %ecx, %edx
cmovgl %edx, %ecx
cmpl %esi, %ecx
jg 0x291e3
negl %eax
movq (%rsp), %rcx
movl %eax, 0x4(%rcx)
movb 0x14(%r15), %al
movb %al, 0x1c(%r15)
movswq 0x2(%r15), %rax
testq %rax, %rax
jle 0x29332
movswq (%r15), %rcx
addq %rcx, %rax
movb 0x14(%r15), %dl
movq (%rdi,%rcx,8), %rsi
movb %dl, 0x14(%rsi)
incq %rcx
cmpq %rax, %rcx
jl 0x29200
jmp 0x29332
testl %ebp, 0xa66d6(%rip)     # 0xcf8f4
leaq 0x1d4feb(%rip), %rbx    # 0x1fe210
je 0x29298
leaq 0x648d9(%rip), %rdi     # 0x8db07
callq 0x2be4a
movl $0x8, %ecx
cmpl $0x4000, %eax           # imm = 0x4000
jl 0x29246
movl $0xc, %ecx
je 0x29251
movq (%rsp), %rax
movb (%rax,%rcx), %al
movb %al, 0x14(%r15)
movb 0x14(%r15), %al
movb %al, 0x1c(%r15)
movswq 0x2(%r15), %rax
testq %rax, %rax
jle 0x29332
movswq (%r15), %rcx
addq %rcx, %rax
movb 0x14(%r15), %dl
movq (%rbx,%rcx,8), %rsi
movb %dl, 0x14(%rsi)
incq %rcx
cmpq %rax, %rcx
jl 0x2926e
jmp 0x29332
cmpl %ecx, %edx
cmovll %edx, %ecx
cmpl %esi, %ecx
jge 0x291da
jmp 0x291e3
testl %ebp, 0xa666a(%rip)     # 0xcf908
je 0x292b5
movsbl 0x14(%r15), %ecx
movl 0xc(%rdx), %eax
cmpl %ecx, %eax
jne 0x292fe
movb 0x8(%rdx), %al
movb %al, 0x14(%r15)
jmp 0x29306
testl %ebp, 0xa6651(%rip)     # 0xcf90c
je 0x29332
movsbl 0x14(%r15), %ecx
movq (%rsp), %rdx
movl 0xc(%rdx), %eax
cmpl %ecx, %eax
jne 0x292d0
movl 0x8(%rdx), %eax
movb %al, 0x14(%r15)
movb %al, 0x1c(%r15)
movswq 0x2(%r15), %rax
testq %rax, %rax
jle 0x29332
movswq (%r15), %rcx
addq %rcx, %rax
movb 0x14(%r15), %dl
movq (%rbx,%rcx,8), %rsi
movb %dl, 0x14(%rsi)
incq %rcx
cmpq %rax, %rcx
jl 0x292e9
jmp 0x29332
movb %al, 0x14(%r15)
sarl $0x2, 0x10(%rdx)
movb 0x14(%r15), %al
movb %al, 0x1c(%r15)
movswq 0x2(%r15), %rax
testq %rax, %rax
jle 0x29332
movswq (%r15), %rcx
addq %rcx, %rax
movb 0x14(%r15), %dl
movq (%rbx,%rcx,8), %rsi
movb %dl, 0x14(%rsi)
incq %rcx
cmpq %rax, %rcx
jl 0x2931f
testl %ebp, 0xa65e0(%rip)     # 0xcf918
leaq 0xb93e1(%rip), %rbx     # 0xe2720
movq (%rsp), %rdx
je 0x2940b
leaq 0x7797c0(%rip), %rax    # 0x7a2b10
movl (%rax), %eax
testl %eax, %eax
js 0x2940b
leaq 0x1cceaf(%rip), %rcx    # 0x1f6210
movq (%rcx,%r12,8), %rcx
movl 0x8(%rcx), %ebp
movl %eax, %r14d
movswl (%rbx,%r14,2), %eax
cmpl %eax, %r12d
jne 0x293ec
leaq 0xb81d4(%rip), %rax     # 0xe1550
movl (%rax,%r14,4), %eax
subl %ebp, %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
cmpl $0x2800, %ecx           # imm = 0x2800
jb 0x2939d
leaq 0x103178(%rip), %rax    # 0x12c510
cmpl $0x7, (%rax)
jne 0x293ec
leaq 0x2e95ac(%rip), %rax    # 0x312950
movslq (%rax,%r12,4), %rax
cmpq $-0x1, %rax
je 0x29401
leaq 0x2ed85b(%rip), %rcx    # 0x316c10
movq (%rcx,%rax,8), %rax
cmpl $0x0, (%rax)
je 0x293ec
movzwl 0x38(%rdx), %eax
xorl %ecx, %ecx
subw %ax, %cx
movswl %cx, %esi
movswl %r14w, %ebx
movl %ebx, %edi
callq 0xa5d8
movl %ebx, %edi
leaq 0xb9342(%rip), %rbx     # 0xe2720
movl $0xfffffff6, %esi       # imm = 0xFFFFFFF6
callq 0xa70f
movq (%rsp), %rdx
leaq 0x77972d(%rip), %rax    # 0x7a2b20
movl (%rax,%r14,4), %eax
testl %eax, %eax
jns 0x29368
jmp 0x2940b
movl 0x10(%rdx), %eax
cmpl 0x14(%rdx), %eax
je 0x293be
jmp 0x293ec
movq 0x20(%rsp), %rbx
incq %rbx
movslq 0x2940ba(%rip), %rax    # 0x2bd4d4
cmpq %rax, %rbx
jl 0x28efa
leaq 0xa554e(%rip), %rax     # 0xce978
cmpb $0x0, 0x4(%rax)
jne 0x29484
cmpl $0x0, 0x301fc9(%rip)    # 0x32b400
jle 0x2944c
xorl %ebx, %ebx
movl %ebx, %edi
callq 0x2beac
incl %ebx
cmpl 0x301fb6(%rip), %ebx    # 0x32b400
jl 0x2943b
cmpl $0x0, 0x2e94ed(%rip)    # 0x312940
jle 0x29468
xorl %ebx, %ebx
movl %ebx, %edi
callq 0x2c06c
incl %ebx
cmpl 0x2e94da(%rip), %ebx    # 0x312940
jl 0x29457
cmpl $0x0, 0x2efa51(%rip)    # 0x318ec0
jle 0x29484
xorl %ebx, %ebx
movl %ebx, %edi
callq 0x2c2f0
incl %ebx
cmpl 0x2efa3e(%rip), %ebx    # 0x318ec0
jl 0x29473
callq 0x2cb3a
callq 0x2cc11
leaq 0xb7ff3(%rip), %rax     # 0xe1488
movl (%rax), %eax
subl 0x302683(%rip), %eax    # 0x32bb20
cmpl $0x79, %eax
jl 0x294bf
leaq 0xb7fb5(%rip), %rax     # 0xe145e
movswl (%rax), %edi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2aacf
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq