// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/src/tekstat.c
// Function: enemygunshot
void
enemygunshot(int  sn)
{
     int       j,nextj,ext;
     int      dist;

    #ifdef PLRSPRDEBUG
     if( isaplayersprite(sn) ) {
          crashgame("messing w plrsprite at 14");
     }
    #endif

	j=headspritestat[STROLL];
    	while( j != -1 ) {
		nextj = nextspritestat[j];

          ext=sprptr[j]->extra;
          if( !validext(ext) ) {
               noextcrashgame(sn,100);
          }
     	dist = abs(sprptr[sn]->x-sprptr[j]->x)+abs(sprptr[sn]->y-sprptr[j]->y);
 		if( dist < HEARGUNSHOTDIST ) {
               sprXTptr[ext]->aimask|=AI_JUSTSHOTAT;
          }

		j = nextj;
	}

	j=headspritestat[STANDING];
    	while( j != -1 ) {
		nextj = nextspritestat[j];

          ext=sprptr[j]->extra;
          if( !validext(ext) ) {
               noextcrashgame(sn,101);
          }

          // guards not woken by enemies gun shot
          if( sprXTptr[ext]->basestat != GUARD ) {
     	     dist = abs(sprptr[sn]->x-sprptr[j]->x)+abs(sprptr[sn]->y-sprptr[j]->y);
 		     if( dist < HEARGUNSHOTDIST ) {
                    sprXTptr[ext]->aimask|=AI_JUSTSHOTAT;
               }
          }

		j = nextj;
	}

    #ifdef WAKEUPGUARDSBYENEMYGUNSHOT
	j=headspritestat[GUARD];
    	while( j != -1 ) {
		nextj = nextspritestat[j];

          if( j == sn ) {
               j=nextj;
               continue;
          }

          ext=sprptr[j]->extra;
          if( !validext(ext) ) {
               noextcrashgame(sn,102);
          }
     	dist = labs(sprptr[sn]->x-sprptr[j]->x)+labs(sprptr[sn]->y-sprptr[j]->y);
 		if( dist < HEARGUNSHOTDIST ) {
               sprXTptr[ext]->aimask|=AI_JUSTSHOTAT;
          }

		j = nextj;
	}
    #endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movl -0x4(%rbp), %edi
callq 0x2aec0
cmpl $0x0, %eax
je 0x30c06
leaq 0xa9947(%rip), %rdi     # 0xda546
movb $0x0, %al
callq 0x44240
leaq 0x587743(%rip), %rax    # 0x5b8350
movswl 0x1a2(%rax), %eax
movl %eax, -0x8(%rbp)
cmpl $-0x1, -0x8(%rbp)
je 0x30cea
movslq -0x8(%rbp), %rcx
leaq 0x58ff34(%rip), %rax    # 0x5c0b60
movswl (%rax,%rcx,2), %eax
movl %eax, -0xc(%rbp)
movslq -0x8(%rbp), %rcx
leaq 0x1495a2(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movswl 0x2a(%rax), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %edi
callq 0x2ae90
cmpl $0x0, %eax
jne 0x30c63
movl -0x4(%rbp), %edi
movl $0x64, %esi
callq 0x2b180
movslq -0x4(%rbp), %rcx
leaq 0x149572(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movl (%rax), %eax
movslq -0x8(%rbp), %rdx
leaq 0x149561(%rip), %rcx    # 0x17a1e0
movq (%rcx,%rdx,8), %rcx
subl (%rcx), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movslq -0x4(%rbp), %rdx
leaq 0x149549(%rip), %rcx    # 0x17a1e0
movq (%rcx,%rdx,8), %rcx
movl 0x4(%rcx), %ecx
movslq -0x8(%rbp), %rsi
leaq 0x149537(%rip), %rdx    # 0x17a1e0
movq (%rdx,%rsi,8), %rdx
subl 0x4(%rdx), %ecx
movl %ecx, %edx
negl %edx
cmovnsl %edx, %ecx
addl %ecx, %eax
movl %eax, -0x14(%rbp)
cmpl $0x2800, -0x14(%rbp)    # imm = 0x2800
jge 0x30cdf
movslq -0x10(%rbp), %rcx
leaq 0x1f1510(%rip), %rax    # 0x2221e0
movq (%rax,%rcx,8), %rax
movzwl 0x6(%rax), %ecx
orl $0x4, %ecx
movw %cx, 0x6(%rax)
movl -0xc(%rbp), %eax
movl %eax, -0x8(%rbp)
jmp 0x30c17
leaq 0x58765f(%rip), %rax    # 0x5b8350
movswl 0x192(%rax), %eax
movl %eax, -0x8(%rbp)
cmpl $-0x1, -0x8(%rbp)
je 0x30dea
movslq -0x8(%rbp), %rcx
leaq 0x58fe50(%rip), %rax    # 0x5c0b60
movswl (%rax,%rcx,2), %eax
movl %eax, -0xc(%rbp)
movslq -0x8(%rbp), %rcx
leaq 0x1494be(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movswl 0x2a(%rax), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %edi
callq 0x2ae90
cmpl $0x0, %eax
jne 0x30d47
movl -0x4(%rbp), %edi
movl $0x65, %esi
callq 0x2b180
movslq -0x10(%rbp), %rcx
leaq 0x1f148e(%rip), %rax    # 0x2221e0
movq (%rax,%rcx,8), %rax
movswl 0x8(%rax), %eax
cmpl $0xcb, %eax
je 0x30ddf
movslq -0x4(%rbp), %rcx
leaq 0x149474(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movl (%rax), %eax
movslq -0x8(%rbp), %rdx
leaq 0x149463(%rip), %rcx    # 0x17a1e0
movq (%rcx,%rdx,8), %rcx
subl (%rcx), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movslq -0x4(%rbp), %rdx
leaq 0x14944b(%rip), %rcx    # 0x17a1e0
movq (%rcx,%rdx,8), %rcx
movl 0x4(%rcx), %ecx
movslq -0x8(%rbp), %rsi
leaq 0x149439(%rip), %rdx    # 0x17a1e0
movq (%rdx,%rsi,8), %rdx
subl 0x4(%rdx), %ecx
movl %ecx, %edx
negl %edx
cmovnsl %edx, %ecx
addl %ecx, %eax
movl %eax, -0x14(%rbp)
cmpl $0x2800, -0x14(%rbp)    # imm = 0x2800
jge 0x30ddd
movslq -0x10(%rbp), %rcx
leaq 0x1f1412(%rip), %rax    # 0x2221e0
movq (%rax,%rcx,8), %rax
movzwl 0x6(%rax), %ecx
orl $0x4, %ecx
movw %cx, 0x6(%rax)
jmp 0x30ddf
movl -0xc(%rbp), %eax
movl %eax, -0x8(%rbp)
jmp 0x30cfb
addq $0x20, %rsp
popq %rbp
retq