// File: /workspace/github_c_makefile_star2_O2/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 0xb3469(%rip), %r13     # 0xdb720
movswq (%r13,%rbx,2), %rax
leaq 0x2ce23c(%rip), %rcx    # 0x2f6500
movq (%rcx,%rax,8), %r14
imulq $0x28, %rax, %rdx
leaq 0x3c260d(%rip), %rcx    # 0x3ea8e0
cmpw $0x19, 0x22(%rcx,%rdx)
jne 0x28302
leaq 0x9f696(%rip), %rsi     # 0xc7978
cmpb $0x0, 0x4(%rsi)
jne 0x28302
addq %rdx, %rcx
movswl 0x24(%rcx), %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x15d3f
movl %edi, 0x4(%rsp)
leaq 0x1c6f23(%rip), %rbp    # 0x1ef230
movq (%rbp,%rax,8), %rax
cmpw $0x4, 0x22(%rax)
jne 0x2833b
leaq 0xb21b0(%rip), %rax     # 0xda4d0
movl (%rax,%rbx,4), %esi
leaq 0xb21e6(%rip), %rax     # 0xda510
movl (%rax,%rbx,4), %edx
pushq $0xb
popq %rdi
pushq $0x2
popq %r8
xorl %ecx, %ecx
callq 0x1ab2a
testq %r14, %r14
je 0x28412
cmpl $0x0, 0x20(%r14)
js 0x28412
addq $0x20, %r14
leaq 0xb33f6(%rip), %rax     # 0xdb750
movswl (%rax,%rbx,2), %eax
movslq %eax, %r15
imulq $0x2c, %r15, %rax
leaq 0x3fb7c4(%rip), %rcx    # 0x423b30
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 0x28210
imulq $0xc, %r15, %rsi
addq 0x9ec22(%rip), %rsi     # 0xc6fb8
pushq $0x3
popq %rdx
movq %r12, %rdi
callq 0x56a36
movswl (%r14), %esi
movl %r15d, %edi
callq 0x43fe1
leaq 0xb339c(%rip), %rax     # 0xdb750
movswq (%rax,%rbx,2), %rax
imulq $0x2c, %rax, %rax
leaq 0x3fb76c(%rip), %rdi    # 0x423b30
movl (%rdi,%rax), %ecx
leaq 0xb2102(%rip), %rdx     # 0xda4d0
movl %ecx, (%rdx,%rbx,4)
movl 0x4(%rdi,%rax), %ecx
leaq 0xb2134(%rip), %rdx     # 0xda510
movl %ecx, (%rdx,%rbx,4)
movl 0x8(%rdi,%rax), %ecx
leaq 0xb2166(%rip), %rdx     # 0xda550
movl %ecx, (%rdx,%rbx,4)
movzwl 0x1c(%rdi,%rax), %edx
leaq 0xb20b7(%rip), %rsi     # 0xda4b0
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 0x773717(%rip), %r14    # 0x79bb30
leaq 0x545790(%rip), %rbx    # 0x56dbb0
leaq 0xfee09(%rip), %r12     # 0x127230
movslq (%r14), %r14
testq %r14, %r14
js 0x284f3
movswq (%r13,%r14,2), %rax
movq (%rbp,%rax,8), %rax
movzwl 0x22(%rax), %eax
decl %eax
cmpw $0x1, %ax
ja 0x284e3
leaq 0x54e98b(%rip), %rax    # 0x576de0
movzwl (%rax), %eax
xorl %r15d, %r15d
movswq %ax, %rcx
cmpq %rcx, %r15
jge 0x284a2
movq (%rbp,%r15,8), %rcx
movzwl 0x24(%rcx), %edx
movswq (%r13,%r14,2), %rsi
movq (%rbp,%rsi,8), %rsi
cmpw 0x24(%rsi), %dx
jne 0x2849d
movzwl 0x22(%rcx), %ecx
decl %ecx
cmpw $0x2, %cx
jb 0x2849d
movswl %r15w, %edi
callq 0x253e8
leaq 0x54e946(%rip), %rax    # 0x576de0
movzwl (%rax), %eax
incq %r15
jmp 0x2845b
leaq 0x53cef7(%rip), %rax    # 0x5653a0
movzwl (%rax), %r15d
cmpw $-0x1, %r15w
je 0x284e3
movl %r15d, %eax
movswq %r15w, %rcx
movzwl (%rbx,%rcx,2), %r15d
movq (%r12,%rcx,8), %rcx
movzwl 0x28(%rcx), %ecx
movswq (%r13,%r14,2), %rdx
movq (%rbp,%rdx,8), %rdx
cmpw 0x24(%rdx), %cx
jne 0x284ad
movswl %ax, %edi
callq 0x1c9b0
jmp 0x284ad
shlq $0x2, %r14
addq 0x9eaf2(%rip), %r14     # 0xc6fe0
jmp 0x28427
movswl 0x4(%rsp), %ebx
movl %ebx, %edi
callq 0x28514
movl %ebx, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1e805