// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/src/tektag.c
// Function: teknewsector
void
teknewsector(short p)
{
     int           i,n,nexti,s;
     int           sn;
     struct    sectoreffect   *septr;

     s=cursectnum[p];
     septr=septrlist[s];

     #define NEWMAPLOTAG 25
     if( (sector[s].lotag == NEWMAPLOTAG) && (option[4] == 0) ) {
          newmap(sector[s].hitag);
          return;
     }

     if( sectptr[cursectnum[p]]->lotag == 4 ) {
          playsound(S_SPLASH,posx[p],posy[p],0,ST_UPDATE);
     }

     if( septr != NULL ) {
          if( septr->warpto >= 0 ) {
               sn=playersprite[p];
               tekwarp(&sprite[sn].x,&sprite[sn].y,&sprite[sn].z,( short *)&(septr->warpto));
               copybuf(&sprite[sn].x,&osprite[sn].x,3);
               changespritesect(sn,septr->warpto);
               posx[p] = sprite[playersprite[p]].x;
               posy[p] = sprite[playersprite[p]].y;
               posz[p] = sprite[playersprite[p]].z;
               ang[p] = sprite[playersprite[p]].ang;
               cursectnum[p] = sprite[playersprite[p]].sectnum;
               sprite[playersprite[p]].z += (KENSPLAYERHEIGHT<<8);
          }
     }

     for( n=connecthead; n >= 0; n=connectpoint2[n] ) {
          if( (sectptr[cursectnum[n]]->lotag == 1) || (sectptr[cursectnum[n]]->lotag == 2) ) {
               for( i=0; i < numsectors; i++ ) {
                    if( sectptr[i]->hitag == sectptr[cursectnum[n]]->hitag ) {
                         if( (sectptr[i]->lotag != 1) && (sectptr[i]->lotag != 2) ) {
                              operatesector(i);
                          }
                   }
               }
               i=headspritestat[0];
               while( i != -1 ) {
                    nexti=nextspritestat[i];
                    if( sprptr[i]->hitag == sectptr[cursectnum[n]]->hitag ) {
                         operatesprite(i);
                    }
               i=nexti;
               }
          }
     }

     checkmapsndfx(p);
     sectortriggersprites(p);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movslq %edi, %rbx
leaq 0xb9c14(%rip), %r13     # 0xe5720
movswq (%r13,%rbx,2), %rax
leaq 0x2d49e7(%rip), %rcx    # 0x300500
movq (%rcx,%rax,8), %r14
leaq (%rax,%rax,4), %rcx
leaq 0x3c8db8(%rip), %rdx    # 0x3f48e0
cmpw $0x19, 0x22(%rdx,%rcx,8)
jne 0x2bb58
leaq 0xa5e41(%rip), %rsi     # 0xd1978
cmpb $0x0, 0x4(%rsi)
jne 0x2bb58
leaq (%rdx,%rcx,8), %rax
movswl 0x24(%rax), %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x171b2
movl %edi, 0x4(%rsp)
leaq 0x1cd6cd(%rip), %rbp    # 0x1f9230
movq (%rbp,%rax,8), %rax
cmpw $0x4, 0x22(%rax)
jne 0x2bb95
leaq 0xb895a(%rip), %rax     # 0xe44d0
movl (%rax,%rbx,4), %esi
leaq 0xb8990(%rip), %rax     # 0xe4510
movl (%rax,%rbx,4), %edx
movl $0xb, %edi
xorl %ecx, %ecx
movl $0x2, %r8d
callq 0x1c370
testq %r14, %r14
je 0x2bc72
cmpl $0x0, 0x20(%r14)
js 0x2bc72
addq $0x20, %r14
leaq 0xb9b9c(%rip), %rax     # 0xe5750
movswl (%rax,%rbx,2), %eax
movslq %eax, %r15
imulq $0x2c, %r15, %rax
leaq 0x401f6a(%rip), %rcx    # 0x42db30
leaq (%rcx,%rax), %r12
leaq (%rcx,%rax), %rsi
addq $0x4, %rsi
leaq (%rcx,%rax), %rdx
addq $0x8, %rdx
movq %r12, %rdi
movq %r14, %rcx
callq 0x2ba59
leaq (%r15,%r15,2), %rsi
shlq $0x2, %rsi
addq 0xa53bc(%rip), %rsi     # 0xd0fb0
movq %r12, %rdi
movl $0x3, %edx
callq 0x6110e
movswl (%r14), %esi
movl %r15d, %edi
callq 0x48b21
leaq 0xb9b3c(%rip), %rax     # 0xe5750
movswq (%rax,%rbx,2), %rax
imulq $0x2c, %rax, %rax
leaq 0x401f0c(%rip), %rdi    # 0x42db30
movl (%rdi,%rax), %ecx
leaq 0xb88a2(%rip), %rdx     # 0xe44d0
movl %ecx, (%rdx,%rbx,4)
movl 0x4(%rdi,%rax), %ecx
leaq 0xb88d4(%rip), %rdx     # 0xe4510
movl %ecx, (%rdx,%rbx,4)
movl 0x8(%rdi,%rax), %ecx
leaq 0xb8906(%rip), %rdx     # 0xe4550
movl %ecx, (%rdx,%rbx,4)
movzwl 0x1c(%rdi,%rax), %edx
leaq 0xb8857(%rip), %rsi     # 0xe44b0
movw %dx, (%rsi,%rbx,2)
movzwl 0x18(%rdi,%rax), %edx
movw %dx, (%r13,%rbx,2)
addl $0x2200, %ecx           # imm = 0x2200
movl %ecx, 0x8(%rdi,%rax)
leaq 0x779eb7(%rip), %rax    # 0x7a5b30
movl (%rax), %eax
testl %eax, %eax
js 0x2bd5d
leaq 0x54bf26(%rip), %r12    # 0x577bb0
leaq 0x10559f(%rip), %rbx    # 0x131230
movl %eax, %r15d
movswq (%r13,%r15,2), %rax
movq (%rbp,%rax,8), %rax
movzwl 0x22(%rax), %eax
decl %eax
cmpw $0x1, %ax
ja 0x2bd4a
leaq 0x55512a(%rip), %rax    # 0x580de0
movzwl (%rax), %eax
testw %ax, %ax
jle 0x2bd06
xorl %r14d, %r14d
movq (%rbp,%r14,8), %rcx
movzwl 0x24(%rcx), %edx
movswq (%r13,%r15,2), %rsi
movq (%rbp,%rsi,8), %rsi
cmpw 0x24(%rsi), %dx
jne 0x2bcfa
movzwl 0x22(%rcx), %ecx
decl %ecx
cmpw $0x2, %cx
jb 0x2bcfa
movswl %r14w, %edi
callq 0x27c8c
leaq 0x5550e9(%rip), %rax    # 0x580de0
movzwl (%rax), %eax
incq %r14
movswq %ax, %rcx
cmpq %rcx, %r14
jl 0x2bcc1
leaq 0x543693(%rip), %rax    # 0x56f3a0
movzwl (%rax), %eax
cmpw $-0x1, %ax
je 0x2bd4a
movswq %ax, %rcx
movzwl (%r12,%rcx,2), %r14d
movq (%rbx,%rcx,8), %rcx
movzwl 0x28(%rcx), %ecx
movswq (%r13,%r15,2), %rdx
movq (%rbp,%rdx,8), %rdx
cmpw 0x24(%rdx), %cx
jne 0x2bd40
movswl %ax, %edi
callq 0x1e559
movl %r14d, %eax
cmpw $-0x1, %r14w
jne 0x2bd16
leaq 0x779def(%rip), %rax    # 0x7a5b40
movl (%rax,%r15,4), %eax
testl %eax, %eax
jns 0x2bc91
movswl 0x4(%rsp), %ebx
movl %ebx, %edi
callq 0x2bd7e
movl %ebx, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x205b3