// File: /workspace/github_c_makefile_star2_O1/jonof[P]jftekwar/src/tekstat.c
// Function: sectortriggersprites
void
sectortriggersprites(short snum)
{
     short     i,nexti,ext;
     char      triggered=0;

     if( option[4] != 0 ) {
          return;
     }

     if( !validplayer(snum) ) {
          crashgame("sectrtrgrsprts: bad plrnum");
     }

     if( sectptr[cursectnum[snum]]->lotag == SECT_LOTAG_SHOWMESSAGE ) {
           switch( sectptr[cursectnum[snum]]->hitag ) {
           case 0:
                 showmessage("AREA IS OFF-LIMITS");
                 break;
           }
           return;
     }
     if( sectptr[cursectnum[snum]]->lotag != SECT_LOTAG_TRIGGERSPRITE ) {
          return;
     }

     i=headspritestat[INANIMATE];
     while (i != -1) {
          nexti=nextspritestat[i];
          if (sprptr[i]->hitag == sectptr[cursectnum[snum]]->hitag) {
               triggersprite(i);
               triggered=1;
          }
          i=nexti;
     }

     i=headspritestat[AMBUSH];
     while (i != -1) {
          nexti=nextspritestat[i];
          if( sprptr[i]->hitag == sectptr[cursectnum[snum]]->hitag ) {
               ext=sprptr[i]->extra;
               if( !validext(ext) ) {
                    noextcrashgame(i, 300);
               }
               sprXTptr[i]->aimask|=AI_JUSTSHOTAT;
               ambushyell(i, ext);
               triggered=1;
          }
          i=nexti;
     }

     i=headspritestat[GUARD];
     while (i != -1) {
          nexti=nextspritestat[i];
          if( sprptr[i]->hitag == sectptr[cursectnum[snum]]->hitag ) {
               if( (ext=sprptr[i]->extra) != -1 ) {
                    sprXTptr[ext]->aimask&=~AI_GAVEWARNING;
                    givewarning(i, ext);
                    sprXTptr[ext]->aimask|=AI_ENCROACHMENT;
                    triggered=1;
               }
          }
          i=nexti;
     }

     i=headspritestat[STANDING];   // check GUARDS who are standing
     while (i != -1) {
          nexti=nextspritestat[i];
          ext=sprptr[i]->extra;
          if( (!validext(ext)) || (sprXTptr[ext]->basestat == GUARD) ) {
               if( sprptr[i]->hitag == sectptr[cursectnum[snum]]->hitag )
                    sprXTptr[ext]->aimask&=~AI_GAVEWARNING;
                    givewarning(i, ext);
                    sprXTptr[ext]->aimask|=AI_ENCROACHMENT;
                    triggered=1;
          }
          i=nexti;
     }

     if( triggered ) {
          sectptr[cursectnum[snum]]->hitag=0;
     }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0xae624(%rip), %rax     # 0xce978
cmpb $0x0, 0x4(%rax)
je 0x20369
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %edi, %ebx
movswl %bx, %edi
callq 0xf210
testl %eax, %eax
jne 0x20385
leaq 0x6d149(%rip), %rdi     # 0x8d4c7
xorl %eax, %eax
callq 0x2d800
movswq %bx, %r15
leaq 0xc2390(%rip), %r12     # 0xe2720
movswq (%r12,%r15,2), %rax
leaq 0x1d5e74(%rip), %r13    # 0x1f6210
movq (%r13,%rax,8), %rax
movzwl 0x22(%rax), %ecx
cmpl $0x139c, %ecx           # imm = 0x139C
je 0x203d8
cmpl $0x13a6, %ecx           # imm = 0x13A6
jne 0x2035a
cmpw $0x0, 0x24(%rax)
jne 0x2035a
leaq 0x6d11f(%rip), %rdi     # 0x8d4e2
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x14b61
leaq 0x54bfa1(%rip), %rax    # 0x56c380
movzwl (%rax), %ecx
xorl %eax, %eax
cmpw $-0x1, %cx
je 0x2042a
leaq 0x55479f(%rip), %rbx    # 0x574b90
leaq 0x10de18(%rip), %r14    # 0x12e210
movswq %cx, %rdx
movzwl (%rbx,%rdx,2), %ebp
movq (%r14,%rdx,8), %rdx
movzwl 0x28(%rdx), %edx
movswq (%r12,%r15,2), %rsi
movq (%r13,%rsi,8), %rsi
cmpw 0x24(%rsi), %dx
jne 0x20422
movswl %cx, %edi
callq 0x1f8cd
movb $0x1, %al
movl %ebp, %ecx
cmpw $-0x1, %bp
jne 0x203f8
leaq 0x54bf4f(%rip), %rcx    # 0x56c380
movzwl 0x194(%rcx), %ebp
cmpw $-0x1, %bp
je 0x204ea
leaq 0x554747(%rip), %rdi    # 0x574b90
leaq 0x10ddc0(%rip), %r8     # 0x12e210
movq %r15, (%rsp)
movswq %bp, %r14
movzwl (%rdi,%r14,2), %ebp
movq (%r8,%r14,8), %rcx
movzwl 0x28(%rcx), %edx
movswq (%r12,%r15,2), %rsi
movq (%r13,%rsi,8), %rsi
cmpw 0x24(%rsi), %dx
jne 0x204e0
movq %r13, %r15
movq %r12, %r13
movq %rdi, %r12
movzwl 0x2a(%rcx), %ebx
cmpl $0x4000, %ebx           # imm = 0x4000
jb 0x204af
imulq $0x2c, %r14, %rax
leaq 0x40a67b(%rip), %rcx    # 0x42ab10
movl (%rcx,%rax), %esi
movl 0x4(%rcx,%rax), %edx
leaq 0x6cf26(%rip), %rdi     # 0x8d3c9
movl $0x12c, %ecx            # imm = 0x12C
xorl %eax, %eax
callq 0x2d800
leaq 0x1b5d5a(%rip), %rax    # 0x1d6210
movq (%rax,%r14,8), %rax
orw $0x4, 0x6(%rax)
movswl %bx, %esi
movl %r14d, %edi
callq 0x2063a
movb $0x1, %al
movq %r12, %rdi
movq %r13, %r12
movq %r15, %r13
movq (%rsp), %r15
leaq 0x10dd30(%rip), %r8     # 0x12e210
cmpw $-0x1, %bp
jne 0x20454
leaq 0x54be8f(%rip), %rcx    # 0x56c380
movzwl 0x196(%rcx), %ebp
cmpw $-0x1, %bp
je 0x2058a
leaq 0x554687(%rip), %r14    # 0x574b90
leaq 0x10dd00(%rip), %r9     # 0x12e210
movl %ebp, %ecx
movswq %bp, %rdx
movzwl (%r14,%rdx,2), %ebp
movq (%r9,%rdx,8), %rdx
movzwl 0x28(%rdx), %esi
movswq (%r12,%r15,2), %rdi
movq (%r13,%rdi,8), %rdi
cmpw 0x24(%rdi), %si
jne 0x20584
movswq 0x2a(%rdx), %rbx
cmpq $-0x1, %rbx
je 0x20584
leaq 0x1b5ccb(%rip), %rax    # 0x1d6210
movq (%rax,%rbx,8), %rax
andw $-0x41, 0x6(%rax)
movswl %cx, %edi
movl %ebx, %esi
movq %r12, %r13
movq %r15, %r12
movq %r9, %r15
callq 0x206fc
movq %r15, %r9
movq %r12, %r15
movq %r13, %r12
leaq 0x1d5c9f(%rip), %r13    # 0x1f6210
leaq 0x1b5c98(%rip), %rax    # 0x1d6210
movq (%rax,%rbx,8), %rax
orw $0x80, 0x6(%rax)
movb $0x1, %al
cmpw $-0x1, %bp
jne 0x20510
leaq 0x54bdef(%rip), %rcx    # 0x56c380
movzwl 0x192(%rcx), %ecx
cmpw $-0x1, %cx
je 0x2061d
leaq 0x1b5c6b(%rip), %rbp    # 0x1d6210
movswq %cx, %rdx
leaq 0x5545e0(%rip), %rsi    # 0x574b90
movzwl (%rsi,%rdx,2), %ebx
leaq 0x10dc55(%rip), %rsi    # 0x12e210
movq (%rsi,%rdx,8), %rdx
movzwl 0x2a(%rdx), %r14d
cmpq $0x3fff, %r14           # imm = 0x3FFF
ja 0x205da
movq (%rbp,%r14,8), %rsi
cmpw $0xcb, 0x8(%rsi)
jne 0x20615
movswq %r14w, %rsi
movzwl 0x28(%rdx), %eax
movswq (%r12,%r15,2), %rdx
movq (%r13,%rdx,8), %rdx
cmpw 0x24(%rdx), %ax
jne 0x205fc
movq (%rbp,%rsi,8), %rax
andw $-0x41, 0x6(%rax)
movswl %cx, %edi
callq 0x206fc
movswq %r14w, %rax
movq (%rbp,%rax,8), %rax
orw $0x80, 0x6(%rax)
movb $0x1, %al
movl %ebx, %ecx
cmpw $-0x1, %bx
jne 0x205a5
testb %al, %al
je 0x2035a
movswq (%r12,%r15,2), %rax
movq (%r13,%rax,8), %rax
movw $0x0, 0x24(%rax)
jmp 0x2035a